/* IS4 Sistemas - Core Stylesheet */
@import url('./lab.css');
:root {
  --primary-blue: #00875a;       /* Brand Green */
  --primary-blue-hover: #006b47;
  --primary-green: #10b981;      /* Bright Emerald Green */
  --primary-green-hover: #059669;
  --bg-main: #f4f6f8;            /* Soft off-white */
  --bg-card: #ffffff;
  --bg-sidebar: #064e3b;         /* Dark forest green sidebar */
  --text-main: #1e293b;          /* Dark slate */
  --text-muted: #64748b;
  --text-white: #ffffff;
  --border-color: #e2e8f0;
  
  --success: #137333;            /* Corporate green */
  --success-bg: #e6f4ea;
  --warning: #b06000;
  --warning-bg: #fef7e0;
  --danger: #c5221f;             /* Corporate red */
  --danger-bg: #fce8e6;
  --info: #1a73e8;
  --neutral: #64748b;
  
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  
  --transition: all 0.2s ease;
  --font-sans: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* TASK-010B: Apariencia y Temas — tarjetas del selector de temas */
.theme-visual-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px -6px rgba(0, 0, 0, 0.14);
}

/* Pestañas de Configuración (Tributaria / Bancaria / Regional / Apariencia / Documentos) */
.settings-tab {
  background: transparent;
  border: 1px solid transparent;
  color: #64748b;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.settings-tab:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.settings-tab.active {
  background: var(--is4-primary, #00875a);
  color: #ffffff;
  border-color: var(--is4-primary, #00875a);
  box-shadow: 0 2px 8px -2px color-mix(in srgb, var(--is4-primary, #00875a) 50%, transparent);
}

.settings-tab-panel {
  display: none;
}

.settings-tab-panel.active {
  display: block;
  animation: fadeInUp 0.3s ease;
}

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

.doc-design-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 10px -4px rgba(0, 0, 0, 0.08);
}

/* Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
}

#app {
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Layout */
.app-container {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 250px;
  background-color: var(--bg-sidebar);
  color: var(--text-white);
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  position: sticky;
  top: 0;
  overflow: hidden;
  transition: var(--transition);
  z-index: 100;
  flex-shrink: 0;
  box-sizing: border-box;
}

.sidebar-header {
  padding: 0.5rem 0.75rem;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #000000;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
  box-sizing: border-box;
  width: 100%;
}

/* Top Bar Session Information */
.top-session-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

@media (max-width: 991px) {
  .top-session-item.top-session-login {
    display: none !important;
  }
}

@media (max-width: 640px) {
  .top-session-info {
    display: none !important;
  }
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.sidebar-brand-logo {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 44px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  user-select: none;
  -webkit-user-drag: none;
  transition: all 0.2s ease;
}

.brand-icon {
  width: 28px;
  height: 28px;
  background: var(--primary-blue);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: white;
  font-size: 0.95rem;
}

.brand-name {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.025em;
  color: white;
}

.brand-name span {
  color: var(--primary-green);
}

.sidebar-menu {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0.4rem 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(148, 163, 184, 0.07) 50%, rgba(15, 23, 42, 0.18) 100%);
  border-radius: 10px;
  margin: 0.2rem 0.4rem 0.4rem 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* Sidebar Custom Scrollbar */
.sidebar-menu::-webkit-scrollbar {
  width: 5px;
}
.sidebar-menu::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}
.sidebar-menu::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-full);
}
.sidebar-menu::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.45);
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.8rem;
  line-height: 1.25;
  transition: var(--transition);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
}

.menu-item span {
  flex: 1;
  min-width: 0;
  white-space: normal;
  word-break: break-word;
  line-height: 1.2;
}

.menu-item svg {
  width: 16px;
  height: 16px;
  min-width: 16px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.menu-item:hover {
  color: white;
  background-color: rgba(255, 255, 255, 0.08);
  transform: translateX(2px);
}

.menu-item.active {
  color: white;
  background-color: var(--primary-green);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
  font-weight: 700;
}

/* Sidebar Accordion Group Styles */
.menu-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.1rem;
}

.menu-group-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 1.25;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  border-radius: var(--radius-md);
  box-sizing: border-box;
}

.menu-group-header span {
  flex: 1;
  min-width: 0;
  white-space: normal;
  word-break: break-word;
  line-height: 1.2;
}

.menu-group-header:hover {
  color: white;
  background-color: rgba(255, 255, 255, 0.08);
  transform: translateX(2px);
}

.menu-group-header svg.menu-icon {
  width: 16px;
  height: 16px;
  min-width: 16px;
  flex-shrink: 0;
}
.menu-group-header .chevron-icon {
  width: 12px;
  height: 12px;
  min-width: 12px;
  margin-left: auto;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}

.menu-group.open .menu-group-header {
  color: white;
}

.menu-group.open .chevron-icon {
  transform: rotate(180deg);
  color: rgba(255, 255, 255, 0.9);
}

.menu-group-content {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding-left: 0.45rem;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  margin-left: 0.85rem;
  transition: max-height 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
              opacity 0.2s ease,
              padding 0.25s ease;
}

.menu-group.open .menu-group-content {
  opacity: 1;
}

.submenu-item {
  font-size: 0.76rem;
  font-weight: 500;
  padding: 0.38rem 0.5rem;
  gap: 0.45rem;
}

.submenu-item svg {
  width: 14px;
  height: 14px;
  min-width: 14px;
}

.sidebar-footer {
  padding: 0.45rem 0.6rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background-color: rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

/* Quick Logout Button */
.quick-logout-btn {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  cursor: pointer;
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  margin-left: auto;
  flex-shrink: 0;
}

.quick-logout-btn:hover {
  color: #ffffff;
  background-color: #dc2626;
  border-color: #ef4444;
}

.user-profile-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.user-details {
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.user-name {
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 1.2;
  white-space: normal;
  word-break: break-word;
}

.user-role {
  font-size: 0.62rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

/* Main Content */
.main-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.top-bar {
  background: white;
  height: 70px;
  border-bottom: 1px solid var(--border-color);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.menu-toggle {
  background: none;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  display: none;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.tenant-selector-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-main);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 0.875rem;
}

.tenant-logo {
  height: 24px;
  max-width: 100px;
  object-fit: contain;
}

.lang-selector, .currency-selector {
  background: none;
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-main);
}

.lang-selector:focus, .currency-selector:focus {
  outline: 2px solid var(--primary-green);
}

/* Page Wrapper */
.content-wrapper {
  padding: 2rem;
  flex: 1;
  overflow-y: auto;
  animation: fadeIn 0.4s ease-out;
}

/* Cards & Layout grids */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition);
}

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

.metric-details h3 {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.metric-val {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

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

.metric-icon.green {
  background: rgba(16, 185, 129, 0.1);
  color: var(--primary-green);
}

.metric-icon.blue {
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary-blue);
}

.metric-icon.orange {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

/* Base components */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.card-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  gap: 1rem;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Grids & Panels */
.panel-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

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

/* Dashboard Middle Grid (Chart 70% + Card 30%) */
.dashboard-middle-grid {
  display: grid;
  grid-template-columns: 7fr 3fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

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

/* Chart loading spinner & keyframes */
.chart-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #e2e8f0;
  border-top-color: #10b981;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* UI Elements */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--primary-green);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.badge-neutral {
  background: rgba(100, 116, 139, 0.1);
  color: var(--neutral);
}

.badge-info {
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary-blue);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background-color: var(--is4-primary, var(--primary-green));
  color: var(--is4-button-text, white);
  border-radius: var(--is4-button-radius, var(--radius-md));
}

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

.btn-secondary {
  background-color: var(--is4-surface, white);
  border-color: var(--is4-border, var(--border-color));
  color: var(--is4-text, var(--text-main));
  border-radius: var(--is4-button-radius, var(--radius-md));
}

.btn-secondary:hover {
  background-color: var(--is4-surface-alt, var(--bg-main));
}

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

.btn-danger:hover {
  background-color: #dc2626;
}

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

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

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

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--is4-border, var(--border-color));
  background: var(--is4-surface, white);
  cursor: pointer;
  color: var(--is4-text, var(--text-main));
  transition: var(--transition);
}

.icon-btn:hover {
  background: var(--is4-surface-alt, var(--bg-main));
}

.icon-btn.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.form-control {
  width: 100%;
  padding: var(--is4-input-pad, 0.625rem 0.875rem);
  font-family: var(--is4-font-family, var(--font-sans));
  font-size: var(--is4-font-size-base, 0.9rem);
  color: var(--is4-text, var(--text-main));
  background-color: var(--is4-surface, white);
  border: var(--is4-border-width, 1px) solid var(--is4-border, var(--border-color));
  border-radius: var(--is4-input-radius, var(--radius-md));
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--is4-primary, var(--primary-green));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--is4-primary, #00875a) 15%, transparent);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
}

/* Tables */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--is4-border, var(--border-color));
  border-radius: var(--radius-md);
  background: var(--is4-surface, white);
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.custom-table th {
  background-color: var(--bg-main);
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.875rem 1.25rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
}

.custom-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

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

.custom-table tbody tr:hover {
  background-color: rgba(248, 250, 252, 0.5);
}

/* Grid filters bar */
.filters-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.filters-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex: 1;
}

.search-input {
  min-width: 240px;
}

/* Login Screen specific */
.login-bg {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 50%, #f6fdf9 0%, #edfcf3 100%);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.login-bg::before {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.03) 0%, rgba(0,0,0,0) 70%);
  top: -10%;
  left: -10%;
}

.login-bg::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(0, 135, 90, 0.03) 0%, rgba(0,0,0,0) 70%);
  bottom: -10%;
  right: -10%;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 2.5rem 2.25rem 2.25rem 2.25rem;
  box-shadow: 0 10px 25px -5px rgba(0, 77, 61, 0.04), 0 20px 30px -10px rgba(0, 0, 0, 0.06);
  color: #334155;
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 10;
  text-align: center;
}

.login-logo-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 1.25rem;
  min-height: 70px;
}

.login-logo-img {
  max-width: 250px;
  max-height: 75px;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.06));
}

.login-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: #004d3d;
  margin-bottom: 0.3rem;
  letter-spacing: -0.01em;
}

.login-subtitle {
  color: #64748b;
  font-size: 0.85rem;
  margin-bottom: 1.75rem;
  font-weight: 500;
}

.login-card .form-group {
  text-align: left;
  margin-bottom: 1.25rem;
}

.login-card .form-label {
  color: #475569;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.45rem;
}

.login-card .form-control {
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  padding: 0.7rem 0.9rem;
  font-size: 0.925rem;
  border-radius: 8px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.01);
  width: 100%;
}

.login-card .form-control:focus {
  border-color: #009664;
  box-shadow: 0 0 0 3px rgba(0, 150, 100, 0.12);
}

.login-card .form-control::placeholder {
  color: #94a3b8;
  opacity: 1;
}

/* Password input with toggle eye */
.pwd-input-group {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.pwd-input-group .form-control {
  padding-right: 2.75rem;
}

.btn-toggle-pwd {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  color: #64748b;
  font-size: 1.15rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.btn-toggle-pwd:hover {
  color: #0f172a;
  background: #f1f5f9;
}

.btn-toggle-pwd:focus {
  outline: 2px solid #009664;
  outline-offset: 1px;
}

.btn-login {
  transition: var(--transition);
}

.btn-login:hover {
  background-color: #008055 !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 150, 100, 0.15);
}

.btn-login:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none !important;
}


/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s ease-out;
}

.modal-content {
  background: var(--is4-surface, white);
  width: 90%;
  max-width: 600px;
  border-radius: var(--is4-modal-radius, var(--radius-lg));
  box-shadow: var(--is4-card-shadow, var(--shadow-lg));
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background-color: var(--bg-main);
}

/* Technical electronic spec images */
.board-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 0.75rem;
}

.board-image-card {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
  background: var(--bg-main);
  box-shadow: var(--shadow-sm);
}

.board-image-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
  transition: var(--transition);
}

.board-image-card img:hover {
  transform: scale(1.05);
}

.board-img-label {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board-img-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(239, 68, 68, 0.9);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  width: 24px;
  height: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.board-img-delete:hover {
  background: rgb(239, 68, 68);
}

/* Image Zoom Overlay Viewer */
.image-zoom-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.image-zoom-container {
  max-width: 90%;
  max-height: 80vh;
  position: relative;
  overflow: auto;
  cursor: zoom-in;
}

.image-zoom-container img {
  max-width: 100%;
  display: block;
  margin: auto;
  transition: transform 0.25s ease;
}

.zoom-controls {
  margin-top: 1.5rem;
  display: flex;
  gap: 1rem;
}

.zoom-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: var(--transition);
}

.zoom-close:hover {
  background: rgba(255, 255, 255, 0.4);
}

/* Bill Billing items grid */
.bill-builder {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}

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

.bill-items-table {
  width: 100%;
  margin-bottom: 1rem;
}

.bill-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  font-size: 0.95rem;
}

.bill-summary-total {
  border-top: 1px solid var(--border-color);
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-green);
}

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

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

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

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

/* Responsive Sidebar details */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -260px;
    height: 100vh;
  }
  
  .sidebar.open {
    left: 0;
  }
  
  .menu-toggle {
    display: block;
  }
  
  .top-bar {
    padding: 0 1rem;
  }
  
  .content-wrapper {
    padding: 1.25rem;
  }
}

/* PRINT FORMATS */
@media print {
  body {
    background: white !important;
    color: black !important;
  }
  
  .sidebar, .top-bar, .btn, .filters-bar, .icon-btn, .modal-footer, .zoom-close, .zoom-controls {
    display: none !important;
  }
  
  .app-container {
    display: block !important;
  }
  
  .content-wrapper {
    padding: 0 !important;
  }
  
  /* Ticket / POS Format */
  body.print-pos {
    width: 80mm;
    font-family: 'Courier New', Courier, monospace;
    font-size: 9pt;
    line-height: 1.2;
    padding: 0;
    margin: 0;
  }
  
  body.print-pos .print-ticket-container {
    width: 100%;
    padding: 2mm;
  }
  
  /* Letter Format */
  body.print-letter {
    width: 210mm;
    height: 297mm;
    padding: 15mm;
  }
}

/* Responsive Layout Adjustments */
@media (max-width: 991px) {
  #open-sidebar-btn {
    display: block !important;
  }
  #close-sidebar-btn {
    display: block !important;
  }
  .sidebar {
    position: fixed !important;
    top: 0;
    left: -260px;
    bottom: 0;
    height: 100vh;
    z-index: 300;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .sidebar.open {
    left: 0 !important;
    box-shadow: 10px 0 30px rgba(15,23,42,0.3);
  }
  .main-layout {
    min-width: 100%;
  }
  .top-bar {
    padding: 0 1rem !important;
  }
  .content-wrapper {
    padding: 1rem !important;
  }
  /* Table Responsiveness */
  .table-responsive, table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* Grid Layouts to Single Column on smaller devices */
  .grid-2, .grid-3, .grid-4, .dashboard-stats, .form-row {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
  /* Modals width */
  .modal-content {
    width: 95% !important;
    padding: 1rem !important;
    margin: 10px;
  }
}

@media (max-width: 576px) {
  body {
    font-size: 0.85rem;
  }
  h2.card-title, .section-title {
    font-size: 1.1rem !important;
  }
  .card {
    padding: 1rem !important;
  }
}

/* Card layout for equipment form */
.equip-card {
  background: var(--is4-surface, white);
  border: 1px solid var(--is4-border, var(--border-color));
  border-radius: var(--is4-card-radius, 12px);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--is4-card-shadow, var(--shadow-sm));
}

.equip-card-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Custom Searchable Select */
.searchable-select-container {
  position: relative;
  width: 100%;
}

.searchable-select-trigger {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--is4-border, #cbd5e1);
  border-radius: var(--is4-input-radius, 8px);
  background: var(--is4-surface, white);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-size: 0.9rem;
}

.searchable-select-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--is4-surface, white);
  border: 1px solid var(--is4-border, #cbd5e1);
  border-radius: var(--is4-input-radius, 8px);
  box-shadow: var(--is4-card-shadow, 0 10px 15px -3px rgba(0,0,0,0.1));
  z-index: 120;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 4px;
}

.searchable-select-search {
  padding: 0.5rem;
  border-bottom: 1px solid #f1f5f9;
}

.searchable-select-search input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.85rem;
}

.searchable-select-options {
  max-height: 160px;
  overflow-y: auto;
}

.searchable-select-option {
  padding: 0.55rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: #1e293b;
  transition: background 0.15s;
}

.searchable-select-option:hover {
  background: #f1f5f9;
}

/* Visual Client block */
.client-info-block {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Multi-media technical gallery styles */
.technical-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.technical-gallery-card {
  position: relative;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  background: #f8fafc;
  aspect-ratio: 0.85;
  display: flex;
  flex-direction: column;
}

.technical-gallery-preview {
  flex: 1;
  width: 100%;
  position: relative;
  overflow: hidden;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.technical-gallery-preview img,
.technical-gallery-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.technical-gallery-preview-icon {
  font-size: 2rem;
  color: #94a3b8;
}

.technical-gallery-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(239, 68, 68, 0.9);
  color: white;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  font-weight: bold;
}

.technical-gallery-meta {
  padding: 0.5rem;
  background: var(--is4-surface, white);
  border-top: 1px solid var(--is4-border, var(--border-color));
}

.technical-gallery-select {
  width: 100%;
  font-size: 0.75rem;
  padding: 0.2rem;
  border: 1px solid var(--is4-border, #cbd5e1);
  border-radius: 4px;
}

/* Global Loader Overlays */
.is4-loader-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #0f172a;
  font-family: 'Plus Jakarta Sans', sans-serif;
  box-sizing: border-box;
  opacity: 0;
  transition: opacity 0.25s ease-out;
  pointer-events: auto;
}

/* Local loader fits inside relative parent container */
.is4-loader-overlay.is-local {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  border-radius: inherit;
  padding: 1rem;
}

/* Global loader falls back to viewport */
.is4-loader-overlay.is-global {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
}

.is4-loader-overlay.is-dark {
  background: rgba(15, 23, 42, 0.8);
  color: #ffffff;
}

.is4-loader-overlay.fade-in {
  opacity: 1;
}

/* Logo Premium Container */
.loader-logo-container {
  position: relative;
  width: 160px;
  max-width: 80%;
  height: auto;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 4px 12px rgba(15, 23, 42, 0.08));
  display: flex;
  justify-content: center;
  align-items: center;
}

.is4-loader-overlay.is-dark .loader-logo-container {
  filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.15)) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.loader-logo {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

/* Glowing shimmer overlay running across logo */
.loader-logo-shimmer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    105deg,
    rgba(255, 255, 255, 0) 25%,
    rgba(255, 255, 255, 0.5) 45%,
    rgba(255, 255, 255, 0.8) 50%,
    rgba(255, 255, 255, 0.5) 55%,
    rgba(255, 255, 255, 0) 75%
  );
  background-size: 200% 100%;
  background-position: 150% 0;
  mix-blend-mode: overlay;
  pointer-events: none;
  -webkit-mask-image: url('IMG/justlogo_loader.png');
  mask-image: url('IMG/justlogo_loader.png');
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  animation: logo-shimmer-anim 2.2s infinite ease-in-out;
}

@keyframes logo-shimmer-anim {
  0% {
    background-position: 150% 0;
  }
  100% {
    background-position: -150% 0;
  }
}

/* Thin Progress Bar (3px height) */
.loader-progress-container {
  width: 130px;
  max-width: 70%;
  height: 3px;
  background: rgba(15, 23, 42, 0.08);
  border-radius: 99px;
  overflow: hidden;
  margin: 0.4rem 0;
  position: relative;
}

.is4-loader-overlay.is-dark .loader-progress-container {
  background: rgba(255, 255, 255, 0.15);
}

.loader-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  border-radius: 99px;
  width: 0%;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.loader-progress-bar.indeterminate {
  width: 50%;
  animation: progress-indeterminate 1.6s infinite ease-in-out;
}

@keyframes progress-indeterminate {
  0% {
    left: -50%;
  }
  100% {
    left: 100%;
  }
}

/* Loader Text & Percentage */
.loader-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  margin-top: 0.2rem;
  letter-spacing: 0.2px;
  text-align: center;
  max-width: 90%;
}

.is4-loader-overlay.is-dark .loader-text {
  color: #e2e8f0;
}

.loader-percentage {
  font-size: 0.8rem;
  font-weight: 700;
  color: #3b82f6;
  margin-top: 0.05rem;
}

.is4-loader-overlay.is-dark .loader-percentage {
  color: #60a5fa;
}

/* Upload File Info */
.loader-file-info {
  margin-top: 0.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
  width: 90%;
}

.loader-file-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.is4-loader-overlay.is-dark .loader-file-name {
  color: #cbd5e1;
}

.loader-file-meta {
  font-size: 0.68rem;
  color: #64748b;
  font-weight: 500;
}

.is4-loader-overlay.is-dark .loader-file-meta {
  color: #94a3b8;
}

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

/* --- Visor 360 and Tooltips --- */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%) translateY(5px);
  background-color: #1e293b;
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 9999;
}

[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.modal-360-content {
  width: 90% !important;
  max-width: 1400px !important;
  height: 90vh !important;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  background: var(--is4-surface, white);
  overflow: hidden;
}

.modal-360-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.visor-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 1.5rem;
  overflow-x: auto;
  padding-bottom: 2px;
}

.visor-tab-btn {
  background: none;
  border: none;
  padding: 0.75rem 1.25rem;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.visor-tab-btn:hover {
  color: var(--primary-blue);
  background: #f8fafc;
}

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

.visor-tab-content {
  display: none;
}

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

.visor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.visor-spec-item {
  background: #f8fafc;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.visor-spec-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.visor-spec-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  word-break: break-word;
}

/* Action pill buttons */
.action-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #334155;
  background: #f1f5f9;
  text-align: left;
  line-height: 1;
}

.action-pill svg {
  flex-shrink: 0;
}

.action-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.action-pill.view-btn {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
}
.action-pill.view-btn:hover {
  background: #bae6fd;
}

.action-pill.edit-btn {
  background: #fef3c7;
  color: #d97706;
  border-color: #fde68a;
}
.action-pill.edit-btn:hover {
  background: #fde68a;
}

.action-pill.note-btn {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}
.action-pill.note-btn:hover {
  background: #a7f3d0;
}

.action-pill.ticket-btn {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}
.action-pill.ticket-btn:hover {
  background: #bfdbfe;
}

.action-pill.pdf-btn {
  background: #fff1f2;
  color: #be123c;
  border-color: #fecdd3;
}
.action-pill.pdf-btn:hover {
  background: #fecdd3;
}

/* Compact Table Layout to prevent horizontal overflow */
.table-compact th {
  padding: 0.5rem 0.6rem !important;
  font-size: 0.72rem !important;
}

.table-compact td {
  padding: 0.45rem 0.6rem !important;
  font-size: 0.8rem !important;
}

/* --- Clients Grid Compact Layout (TASK-001) --- */
.clients-grid {
  table-layout: auto;
}

/* TASK-003: horizontal scroll suave + cabecera fija */
.clients-grid-scroll {
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.clients-grid-scroll::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}

.clients-grid-scroll::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 8px;
  border: 2px solid #fff;
}

.clients-grid-scroll::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.clients-grid-scroll::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.clients-grid-main {
  width: 100%;
}

/* TASK-004: hover suave y fila seleccionada (solo fondo, sin alterar texto/iconos) */
.clients-grid-main tbody tr {
  transition: background-color 0.15s ease;
}

.clients-grid-main tbody tr:hover {
  background-color: #f1f5f9;
}

.clients-grid-main tbody tr.row-selected {
  background-color: #e2e8f0;
}

.clients-grid-main thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f8fafc;
  box-shadow: 0 1px 0 0 #e2e8f0;
  white-space: nowrap;
}

.clients-grid-main thead th[data-col] {
  cursor: default;
  user-select: none;
}

.clients-grid.table-compact th {
  padding: 0.4rem 0.5rem !important;
}

.clients-grid.table-compact td {
  padding: 0.25rem 0.5rem !important;
  font-size: 0.78rem !important;
}

.clients-grid .action-pill {
  width: 26px;
  height: 26px;
  padding: 0;
  justify-content: center;
  align-items: center;
  border-radius: 6px;
  line-height: 1;
}

.clients-grid .action-pill svg {
  flex-shrink: 0;
}

/* TASK-FE-XXX: menú compacto de acciones QR / Código de Barras (grid Clientes).
   Solo presentación: agrupa QR + barcode en un toggle colapsado por defecto. */
.clients-grid .identity-actions-wrap {
  position: relative;
  display: inline-flex;
}

.clients-grid .identity-actions-toggle {
  gap: 2px;
}

.clients-grid .identity-actions-toggle[aria-expanded="true"] {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
}

.clients-grid .identity-actions-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  min-width: 178px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.15), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  padding: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.clients-grid .identity-actions-menu[hidden] {
  display: none;
}

.clients-grid .identity-action-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #334155;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  line-height: 1;
}

.clients-grid .identity-action-item:hover {
  background: #f1f5f9;
  color: #0f172a;
}

/* --- Equipos module: grid rediseñada (iconos, acordeón Ver/Editar, paginación, columnas configurables) --- */
.equip-grid .equip-grid-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  padding: 0;
}

.equip-grid .action-pill {
  width: 26px;
  height: 26px;
  padding: 0;
  justify-content: center;
  align-items: center;
  border-radius: 6px;
  line-height: 1;
}

.equip-grid .action-pill svg {
  flex-shrink: 0;
}

.equip-grid .equip-actions-wrap {
  position: relative;
  display: inline-flex;
}

.equip-grid .equip-actions-toggle {
  gap: 2px;
}

.equip-grid .equip-actions-toggle[aria-expanded="true"] {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
}

.equip-grid .equip-actions-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  min-width: 178px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.15), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  padding: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.equip-grid .equip-actions-menu[hidden] {
  display: none;
}

.equip-grid .equip-action-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #334155;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  line-height: 1;
}

.equip-grid .equip-action-item:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.equip-view-config-btn {
  white-space: nowrap;
}

.equip-view-config {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  min-width: 210px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.15), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  padding: 0.5rem;
  display: none;
  flex-direction: column;
  gap: 0.25rem;
}

.equip-view-config .equip-view-config-head {
  font-size: 0.72rem;
  font-weight: 800;
  color: #334155;
  padding: 0.15rem 0.3rem 0.3rem;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 0.25rem;
}

.equip-view-config .equip-view-config-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #334155;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.equip-view-config .equip-view-config-item:hover {
  background: #f1f5f9;
}

.equip-view-config .equip-view-config-item input[type="checkbox"] {
  accent-color: #00875a;
  margin: 0;
}

.equip-view-config .equip-view-config-reset {
  margin-top: 0.35rem;
  align-self: flex-start;
  font-size: 0.72rem;
}

.filters-bar.equip-filters {
  position: relative;
}

.equip-page-btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.equip-page-size {
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #334155;
}

/* --- Clients Module TASK-002 (config panel, docs modal) --- */
.client-docs-badge:hover {
  background: #d1fae5 !important;
  border-color: #00875a;
}

#client-docs-modal .clients-grid.table-compact th {
  padding: 0.35rem 0.5rem !important;
}

#client-docs-modal .clients-grid.table-compact td {
  padding: 0.3rem 0.5rem !important;
  font-size: 0.76rem !important;
}

.client-view-col {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  color: #334155;
  cursor: pointer;
  padding: 0.2rem 0.3rem;
  border-radius: 6px;
}

.client-view-col:hover {
  background: #f1f5f9;
}

.client-view-col input[type="checkbox"] {
  cursor: pointer;
  width: 14px;
  height: 14px;
  accent-color: #00875a;
}

/* Visor 360 Gallery Cards and Images */
.visor-gallery-card {
  border: 1px solid var(--is4-border, #cbd5e1);
  border-radius: 8px;
  padding: 0.5rem;
  background: var(--is4-surface, white);
  text-align: center;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.visor-gallery-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.05);
}

.visor-gallery-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.visor-gallery-img:hover {
  opacity: 0.95;
}

/* Report Builder Scroll & Accessibility */
#report-builder-form {
  max-height: 70vh !important;
  overflow-y: auto !important;
  padding-right: 4px;
}

/* TASK-005: IS4 Location Selector (Catálogo Maestro de Ubicaciones) */
.is4-loc {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.is4-loc-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.is4-loc-title {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--is4-heading-primary, #004d3d);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.is4-loc-geo {
  background: var(--is4-surface, white);
  border: 1px solid var(--is4-border, #cbd5e1);
  color: var(--is4-text, #475569);
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.is4-loc-geo:hover {
  background: #f1f5f9;
}

.is4-loc-geo:disabled {
  opacity: 0.6;
  cursor: default;
}

.is4-loc-search {
  position: relative;
}

.is4-loc-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--is4-surface, white);
  border: 1px solid var(--is4-border, #cbd5e1);
  border-radius: 8px;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12);
  max-height: 220px;
  overflow-y: auto;
  z-index: 50;
}

.is4-loc-result {
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  color: var(--is4-text, #1e293b);
  cursor: pointer;
  border-bottom: 1px solid var(--is4-border, #f1f5f9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.is4-loc-result:hover {
  background: var(--is4-surface-alt, #f0fdf4);
}

.is4-loc-result.is4-loc-empty {
  color: #64748b;
  font-style: italic;
  cursor: default;
}

.is4-loc-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
}

.is4-loc-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.is4-loc-select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--is4-border, #cbd5e1);
  border-radius: 8px;
  font-size: 0.85rem;
  height: 36px;
  box-sizing: border-box;
  background: var(--is4-surface, white);
  color: var(--is4-text, var(--text-main));
}

.is4-loc-manual {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--is4-border, #cbd5e1);
  border-radius: 8px;
  font-size: 0.85rem;
  box-sizing: border-box;
  text-transform: uppercase;
  background: var(--is4-surface, white);
  color: var(--is4-text, var(--text-main));
}

.is4-loc-geo-status {
  font-size: 0.72rem;
  color: #00875a;
  font-weight: 600;
}

/* ==========================================================================
   IS4Notify — Notificaciones modernas del ERP (estándar visual)
   Tipos: success | error | warning | info | progress | saving | loading
   ========================================================================== */
.is4-notify-root {
  --n-bg: #ffffff;
  --n-border: #e2e8f0;
  --n-text: #0f172a;
  --n-text-muted: #64748b;
  --n-shadow: 0 12px 32px -8px rgba(15, 23, 42, 0.18);
  --n-accent: #1a73e8;
  --n-accent-bg: #eff6ff;
  --n-icon-color: #1a73e8;
  --n-close: #94a3b8;
  --n-progress-track: #e2e8f0;

  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 999990;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  width: min(380px, calc(100vw - 2.5rem));
  pointer-events: none;
}

.is4-notify-root.is4-dark,
body[data-theme="dark"] .is4-notify-root {
  --n-bg: #1e293b;
  --n-border: #334155;
  --n-text: #f1f5f9;
  --n-text-muted: #94a3b8;
  --n-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.55);
  --n-progress-track: #334155;
}

.is4-notify {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: var(--n-bg);
  border: 1px solid var(--n-border);
  border-left: 4px solid var(--n-accent);
  border-radius: 12px;
  padding: 0.875rem 1rem;
  box-shadow: var(--n-shadow);
  font-family: 'Plus Jakarta Sans', sans-serif;
  animation: is4NotifyIn 0.32s cubic-bezier(0.21, 1.02, 0.73, 1) forwards;
  position: relative;
  overflow: hidden;
  cursor: default;
}

.is4-notify.is4-leave {
  animation: is4NotifyOut 0.28s ease forwards;
}

.is4-notify-icon {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--n-accent-bg);
  color: var(--n-icon-color);
}

.is4-notify-icon svg {
  width: 18px;
  height: 18px;
}

.is4-notify-body {
  flex: 1;
  min-width: 0;
}

.is4-notify-title {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--n-text);
  margin-bottom: 0.1rem;
  letter-spacing: 0.01em;
}

.is4-notify-message {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--n-text-muted);
  line-height: 1.45;
  white-space: pre-line;
  overflow-wrap: break-word;
}

.is4-notify-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--n-close);
  padding: 0.15rem;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

.is4-notify-close:hover {
  opacity: 1;
}

.is4-notify-close svg {
  width: 15px;
  height: 15px;
}

.is4-notify-progress-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: transparent;
}

.is4-notify-progress-bar {
  height: 100%;
  width: 100%;
  background: var(--n-accent);
  transform-origin: left center;
  transition: transform 0.1s linear;
}

.is4-notify-steps {
  margin-top: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.is4-notify-step {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--n-text-muted);
}

.is4-notify-spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid var(--n-progress-track);
  border-top-color: var(--n-accent);
  animation: is4Spin 0.7s linear infinite;
  flex-shrink: 0;
}

.is4-notify.is4-type-success { --n-accent: #137333; --n-accent-bg: #e6f4ea; --n-icon-color: #137333; }
.is4-notify.is4-type-error   { --n-accent: #c5221f; --n-accent-bg: #fce8e6; --n-icon-color: #c5221f; }
.is4-notify.is4-type-warning { --n-accent: #b06000; --n-accent-bg: #fef7e0; --n-icon-color: #b06000; }
.is4-notify.is4-type-info    { --n-accent: #1a73e8; --n-accent-bg: #eff6ff; --n-icon-color: #1a73e8; }
.is4-notify.is4-type-progress,
.is4-notify.is4-type-saving,
.is4-notify.is4-type-loading {
  --n-accent: #00875a;
  --n-accent-bg: #e6f4ea;
  --n-icon-color: #00875a;
}

@keyframes is4NotifyIn {
  from { opacity: 0; transform: translateX(30px) scale(0.96); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes is4NotifyOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(30px) scale(0.96); }
}

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

/* ==========================================================================
   IS4Dialog — Ventanas de confirmación modernas del ERP (estándar visual)
   ========================================================================== */
.is4-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 999995;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: is4OverlayIn 0.22s ease forwards;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.is4-dialog-overlay.is4-leave {
  animation: is4OverlayOut 0.22s ease forwards;
}

.is4-dialog-card {
  --d-bg: #ffffff;
  --d-border: #e2e8f0;
  --d-text: #0f172a;
  --d-muted: #64748b;
  --d-input-bg: #ffffff;
  --d-input-border: #cbd5e1;
  --d-secondary: #f1f5f9;
  --d-secondary-text: #475569;
  --d-secondary-border: #cbd5e1;

  width: min(420px, calc(100vw - 2.5rem));
  background: var(--d-bg);
  border: 1px solid var(--d-border);
  border-radius: 16px;
  padding: 1.5rem 1.5rem 1.25rem;
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.28);
  animation: is4DialogIn 0.28s cubic-bezier(0.21, 1.02, 0.73, 1) forwards;
}

.is4-dialog-overlay.is4-leave .is4-dialog-card {
  animation: is4DialogOut 0.22s ease forwards;
}

body[data-theme="dark"] .is4-dialog-card,
.is4-dialog-card.is4-dark {
  --d-bg: #1e293b;
  --d-border: #334155;
  --d-text: #f1f5f9;
  --d-muted: #94a3b8;
  --d-input-bg: #0f172a;
  --d-input-border: #475569;
  --d-secondary: #334155;
  --d-secondary-text: #e2e8f0;
  --d-secondary-border: #475569;
}

.is4-dialog-header {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  margin-bottom: 0.9rem;
}

.is4-dialog-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--d-accent-bg, #eff6ff);
  color: var(--d-accent, #1a73e8);
}

.is4-dialog-icon svg {
  width: 22px;
  height: 22px;
}

.is4-dialog-icon.is4-dialog-danger { --d-accent: #c5221f; --d-accent-bg: #fce8e6; }
.is4-dialog-icon.is4-dialog-warning { --d-accent: #b06000; --d-accent-bg: #fef7e0; }
.is4-dialog-icon.is4-dialog-info { --d-accent: #1a73e8; --d-accent-bg: #eff6ff; }
.is4-dialog-icon.is4-dialog-primary { --d-accent: #00875a; --d-accent-bg: #e6f4ea; }

.is4-dialog-title {
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--d-text);
  margin: 0 0 0.2rem;
  line-height: 1.35;
}

.is4-dialog-message {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--d-muted);
  line-height: 1.55;
  white-space: pre-line;
  overflow-wrap: break-word;
}

.is4-dialog-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--d-input-border);
  border-radius: 10px;
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--d-text);
  background: var(--d-input-bg);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  margin-bottom: 1rem;
}

.is4-dialog-input:focus {
  border-color: #00875a;
  box-shadow: 0 0 0 3px rgba(0, 135, 90, 0.15);
}

.is4-dialog-actions {
  display: flex;
  gap: 0.7rem;
  justify-content: flex-end;
  margin-top: 0.35rem;
}

.is4-dialog-btn {
  border: none;
  border-radius: 10px;
  padding: 0.6rem 1.3rem;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background-color 0.15s ease, opacity 0.15s ease;
}

.is4-dialog-btn:active {
  transform: translateY(1px);
}

.is4-dialog-btn:focus-visible {
  outline: 3px solid rgba(0, 135, 90, 0.35);
  outline-offset: 1px;
}

.is4-dialog-btn-cancel {
  background: var(--d-secondary);
  border: 1px solid var(--d-secondary-border);
  color: var(--d-secondary-text);
}

.is4-dialog-btn-cancel:hover {
  filter: brightness(0.97);
}

.is4-dialog-btn-primary {
  background: #00875a;
  color: #ffffff;
}

.is4-dialog-btn-primary:hover {
  background: #006b47;
}

.is4-dialog-btn-danger {
  background: #c5221f;
  color: #ffffff;
}

.is4-dialog-btn-danger:hover {
  background: #a81d1a;
}

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

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

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

@keyframes is4DialogOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(12px) scale(0.96); }
}

/* ==========================================================================
   IS4SmartGrid — Grilla inteligente reutilizable (IS4SmartGrid/CID)
   ========================================================================== */
.is4-sg {
  --sg-bg: var(--is4-surface, var(--bg-card, #ffffff));
  --sg-border: var(--is4-border, var(--border-color, #e2e8f0));
  --sg-text: var(--is4-text, var(--text-main, #1e293b));
  --sg-muted: var(--is4-text-secondary, var(--text-muted, #64748b));
  --sg-head-bg: var(--is4-sg-head-bg, #f8fafc);
  --sg-head-text: var(--is4-sg-head-text, #334155);
  --sg-row-hover: var(--is4-sg-row-hover, #f1f5f9);
  --sg-accent: var(--is4-primary, var(--primary-blue, #00875a));
  --sg-accent-soft: var(--is4-accent-soft, #e6f4ea);
  --sg-sorted: var(--is4-surface-alt, #f0fdf4);
  --sg-input-bg: var(--is4-input-bg, #ffffff);
  font-family: var(--is4-font-family-grid, var(--is4-font-family, var(--font-sans)));

  display: flex;
  flex-direction: column;
  width: 100%;
  background: var(--sg-bg);
  border: 1px solid var(--sg-border);
  border-radius: var(--radius-lg, 12px);
  font-family: var(--font-sans);
  color: var(--sg-text);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

body[data-theme="dark"] .is4-sg {
  --sg-bg: var(--is4-surface, #1e293b);
  --sg-border: var(--is4-border, #334155);
  --sg-text: var(--is4-text, #f1f5f9);
  --sg-muted: var(--is4-text-secondary, #94a3b8);
  --sg-head-bg: var(--is4-sg-head-bg, #0f172a);
  --sg-head-text: var(--is4-sg-head-text, #cbd5e1);
  --sg-row-hover: var(--is4-sg-row-hover, #334155);
  --sg-accent: var(--is4-sg-accent, #10b981);
  --sg-accent-soft: var(--is4-sg-accent-soft, rgba(16, 185, 129, 0.15));
  --sg-sorted: var(--is4-sg-accent-soft, rgba(16, 185, 129, 0.08));
  --sg-input-bg: var(--is4-surface, #0f172a);
}

.is4-sg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--sg-border);
  background: var(--sg-bg);
}

.is4-sg-head-left {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  min-width: 0;
}

.is4-sg-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--sg-text);
  margin: 0;
  white-space: nowrap;
}

.is4-sg-subtitle {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--sg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.is4-sg-head-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.is4-sg-search {
  min-width: 160px;
  padding: 0.42rem 0.7rem;
  font-size: 0.8rem;
  font-family: inherit;
  color: var(--sg-text);
  background: var(--sg-input-bg);
  border: 1px solid var(--sg-border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.is4-sg-search:focus {
  border-color: var(--sg-accent);
  box-shadow: 0 0 0 3px rgba(0, 135, 90, 0.12);
}

.is4-sg-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.42rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--sg-text);
  background: var(--sg-input-bg);
  border: 1px solid var(--sg-border);
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.is4-sg-btn:hover {
  background: var(--sg-row-hover);
  border-color: var(--sg-muted);
}

.is4-sg-btn-gear {
  padding: 0.42rem 0.6rem;
  font-size: 0.85rem;
}

.is4-sg-btn-export { color: var(--info, #1a73e8); }
.is4-sg-btn-kpi   { color: var(--primary-green, #10b981); }

.is4-sg-scroll {
  flex: 1;
  overflow: auto;
  max-height: 58vh;
  min-height: 120px;
  position: relative;
}

.is4-sg-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.is4-sg-thead .is4-sg-th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--sg-head-bg);
  color: var(--sg-head-text);
  font-weight: 700;
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--sg-border);
  white-space: nowrap;
  user-select: none;
}

.is4-sg-sortable {
  cursor: pointer;
}

.is4-sg-sortable:hover {
  color: var(--sg-accent);
}

.is4-sg-sorted {
  background: var(--sg-sorted);
  color: var(--sg-accent);
}

.is4-sg-th-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.is4-sg-sort-arrow {
  font-size: 0.62rem;
  opacity: 0.7;
}

.is4-sg-td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--sg-border);
  color: var(--sg-text);
  vertical-align: middle;
  white-space: nowrap;
}

.is4-sg-align-left   { text-align: left; }
.is4-sg-align-center { text-align: center; }
.is4-sg-align-right  { text-align: right; }

.is4-sg-row {
  transition: background-color 0.12s ease;
}

.is4-sg-row:hover {
  background: var(--sg-row-hover);
}

.is4-sg-row[tabindex="0"] {
  cursor: pointer;
}

.is4-sg-row.is4-sg-selected,
.is4-sg-row.is4-sg-active {
  background: var(--sg-accent-soft);
}

.is4-sg-group-row {
  background: var(--sg-head-bg);
  font-weight: 800;
  color: var(--sg-head-text);
}

.is4-sg-group-row td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--sg-border);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.72rem;
}

.is4-sg-group-count {
  margin-left: 0.5rem;
  font-weight: 700;
  font-size: 0.68rem;
  color: var(--sg-muted);
  background: var(--sg-bg);
  border: 1px solid var(--sg-border);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
}

.is4-sg-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--sg-muted);
  font-weight: 600;
}

/* Footer de totalizadores (sticky, parte inferior de la grilla) */
.is4-sg-foot {
  border-top: 1px solid var(--sg-border);
  background: var(--sg-head-bg);
  flex-shrink: 0;
  overflow-x: auto;
}

.is4-sg-foot-table {
  min-width: 640px;
}

.is4-sg-totals-strip {
  display: flex;
  align-items: stretch;
  gap: 0.2rem;
  padding: 0.55rem 0.75rem;
  overflow-x: auto;
  flex-wrap: wrap;
}

.is4-sg-totals-item {
  flex: 1;
  min-width: 110px;
  background: var(--sg-accent-soft);
  border: 1px solid var(--sg-border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  white-space: nowrap;
}

.is4-sg-totals-label {
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sg-muted);
}

.is4-sg-totals-value {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--sg-accent);
}

.is4-sg-totals-sep {
  width: 1px;
  background: var(--sg-border);
  margin: 0 0.25rem;
}

/* Paginación */
.is4-sg-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--sg-border);
  background: var(--sg-bg);
}

.is4-sg-page-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--sg-muted);
  flex-wrap: wrap;
}

.is4-sg-page-count {
  font-weight: 800;
  color: var(--sg-text);
}

.is4-sg-page-loaded {
  opacity: 0.75;
}

.is4-sg-page-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.is4-sg-page-size {
  padding: 0.32rem 0.45rem;
  font-size: 0.76rem;
  font-family: inherit;
  font-weight: 700;
  color: var(--sg-text);
  background: var(--sg-input-bg);
  border: 1px solid var(--sg-border);
  border-radius: 7px;
  outline: none;
  cursor: pointer;
}

.is4-sg-page-btn {
  min-width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--sg-text);
  background: var(--sg-input-bg);
  border: 1px solid var(--sg-border);
  border-radius: 7px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.is4-sg-page-btn:hover:not(:disabled) {
  background: var(--sg-row-hover);
  border-color: var(--sg-accent);
  color: var(--sg-accent);
}

.is4-sg-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.is4-sg-page-now {
  min-width: 34px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--sg-text);
  background: var(--sg-accent-soft);
  border: 1px solid var(--sg-border);
  border-radius: 7px;
  padding: 0.28rem 0.2rem;
}

/* Popover de configuración de columnas */
.is4-sg-cfg-popover {
  position: fixed;
  z-index: 99990;
  width: min(290px, calc(100vw - 2rem));
  background: var(--sg-bg);
  border: 1px solid var(--sg-border);
  border-radius: 12px;
  box-shadow: 0 16px 32px -8px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  font-family: var(--font-sans);
}

.is4-sg-cfg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  background: var(--sg-head-bg);
  border-bottom: 1px solid var(--sg-border);
  font-size: 0.82rem;
  color: var(--sg-text);
}

.is4-sg-cfg-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--sg-muted);
  line-height: 1;
  padding: 0.1rem 0.3rem;
}

.is4-sg-cfg-list {
  max-height: 280px;
  overflow-y: auto;
  padding: 0.3rem 0;
}

.is4-sg-cfg-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  color: var(--sg-text);
  cursor: pointer;
}

.is4-sg-cfg-item:hover {
  background: var(--sg-row-hover);
}

.is4-sg-cfg-item input[type="checkbox"] {
  accent-color: var(--sg-accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
  flex-shrink: 0;
}

.is4-sg-cfg-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.is4-sg-cfg-locked .is4-sg-cfg-name {
  opacity: 0.55;
}

.is4-sg-cfg-move {
  display: inline-flex;
  gap: 0.2rem;
}

.is4-sg-cfg-mv {
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.68rem;
  color: var(--sg-muted);
  padding: 0.1rem 0.28rem;
}

.is4-sg-cfg-mv:hover {
  color: var(--sg-accent);
  border-color: var(--sg-border);
}

.is4-sg-cfg-actions {
  padding: 0.55rem 0.75rem;
  border-top: 1px solid var(--sg-border);
  background: var(--sg-head-bg);
}

.is4-sg-cfg-restore {
  width: 100%;
  justify-content: center;
  font-size: 0.76rem;
  color: var(--danger, #c5221f);
}

/* Responsive */
@media (max-width: 768px) {
  .is4-sg-head {
    padding: 0.55rem 0.75rem;
  }
  .is4-sg-pagination {
    padding: 0.5rem 0.75rem;
  }
  .is4-sg-title { font-size: 0.88rem; }
  .is4-sg-search { min-width: 120px; }
}

/* ==========================================================================
   IS4Smart Toolbar — Barra inteligente de acciones del módulo (CID)
   Grupos: DOCUMENTOS | EXPORTAR | IMPORTAR | FILTROS | CONFIGURACIÓN
   ========================================================================== */
.bills-smart-toolbar {
  --bt-bg: #ffffff;
  --bt-border: #e2e8f0;
  --bt-muted: #64748b;
  --bt-text: #1e293b;
  --bt-accent: #00875a;

  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1.25rem;
  background: var(--bt-bg);
  border: 1px solid var(--bt-border);
  border-radius: 14px;
  padding: 0.65rem 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

body[data-theme="dark"] .bills-smart-toolbar {
  --bt-bg: #1e293b;
  --bt-border: #334155;
  --bt-text: #f1f5f9;
  --bt-muted: #94a3b8;
}

.bst-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.bst-row-actions {
  border-bottom: 1px dashed var(--bt-border);
  padding-bottom: 0.55rem;
}

.bst-search-zone {
  flex: 1 1 auto;
  min-width: 0;
}

.bst-group-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex: 1 1 auto;
}

.bst-group-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex: 1 1 auto;
}

/* Hide default grid header in billing to avoid duplicate elements */
#bills-smart-grid .is4-sg-head {
  display: none !important;
}

.bst-group-label {
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bt-muted);
  white-space: nowrap;
}

.bst-group-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.bst-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.42rem 0.75rem;
  font-size: 0.76rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--bt-text);
  background: #f8fafc;
  border: 1px solid var(--bt-border);
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.bst-btn:hover {
  border-color: var(--bt-accent);
  color: var(--bt-accent);
  background: #f0fdf4;
}

.bst-btn-primary {
  background: var(--bt-accent);
  border-color: var(--bt-accent);
  color: #ffffff;
}

.bst-btn-primary:hover {
  background: #006b47;
  border-color: #006b47;
  color: #ffffff;
}

.bst-btn-ghost {
  background: transparent;
  color: var(--bt-muted);
  border-color: transparent;
}

.bst-btn-ghost:hover {
  color: var(--danger, #c5221f);
  background: #fce8e6;
  border-color: transparent;
}

.bills-filter-panel {
  margin-top: 0.6rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 0.9rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

body[data-theme="dark"] .bills-filter-panel {
  background: #1e293b;
  border-color: #334155;
}

.bfp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.6rem;
}

.bfp-label {
  display: block;
  font-size: 0.64rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  margin-bottom: 0.25rem;
}

@media (max-width: 768px) {
  .bills-smart-toolbar {
    padding: 0.75rem !important;
    gap: 0.5rem !important;
  }
  .bst-row {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .bst-group-left, .bst-group-right {
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    gap: 0.4rem !important;
  }
  .bst-group-left > div, .bst-group-left > button, 
  .bst-group-right > div, .bst-group-right > button {
    width: 100% !important;
    margin: 0 !important;
    justify-content: center !important;
  }
}

/* TASK-010: Drag & Drop para líneas de documentos comerciales */
.bill-line-component.dragging {
  opacity: 0.45;
  border: 2px dashed #00875a !important;
  box-shadow: 0 10px 20px rgba(0,0,0,0.12) !important;
}

/* TASK-010: Reusable Grid Compact Mode (.is4-sg-compact) */
.is4-sg-compact .is4-sg-table {
  font-size: 0.74rem !important;
}
.is4-sg-compact .is4-sg-thead .is4-sg-th {
  padding: 0.35rem 0.45rem !important;
  font-size: 0.72rem !important;
}
.is4-sg-compact .is4-sg-td {
  padding: 0.3rem 0.45rem !important;
}
.is4-sg-compact .is4-sg-btn {
  padding: 0.25rem 0.5rem !important;
  font-size: 0.72rem !important;
}

/* TASK-010: Aligned Footer totalizers tfoot sticky inside main table */
.is4-sg-scroll {
  flex: 1;
  overflow-x: auto !important;
  overflow-y: auto !important;
  max-height: 58vh;
  min-height: 120px;
  position: relative;
}

.is4-sg-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto !important;
  min-width: 0 !important; /* Escala al 100% disponible; scroll solo cuando las columnas no caben */
}

.is4-sg-tfoot {
  position: sticky !important;
  bottom: 0 !important;
  z-index: 5 !important;
  background: #f1f5f9 !important;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05) !important;
}

.is4-sg-totals-row td {
  border-top: 3px solid #00875a !important; /* Borde verde IS4 */
  background: #f1f5f9 !important; /* Gris suave */
  padding: 0.55rem 0.75rem !important; /* Altura normal de fila */
  font-weight: 700 !important; /* Tipografía más gruesa */
  color: #0f172a !important;
  vertical-align: middle !important;
}

.is4-sg-compact .is4-sg-totals-row td {
  padding: 0.35rem 0.45rem !important;
}

/* TreeView ScriptCase Nodes & Bullet lines */
.treeview-details-row td {
  background: #f8fafc !important;
}

.treeview-detail-container {
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.treeview-nodes-container {
  margin-left: 0.25rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TASK-010B-R1 — CAPA DE THEMING (consumo de variables --is4-*)
   Se apoya sobre las variables inyectadas por js/utils/theme-manager.js.
   TODAS las declaraciones usan `var(--is4-*, fallback)` con el valor actual
   como fallback, de modo que el tema IS4 Original es visualmente idéntico.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Tipografía global ── */
body,
.content-wrapper {
  font-family: var(--is4-font-family, var(--font-sans));
  font-size: var(--is4-font-size-base, 14px);
  font-weight: var(--is4-font-weight-normal, 400);
}

h1, h2, h3, h4, h5, h6,
.card-title,
.is4-sg-title {
  font-family: var(--is4-font-family-heading, var(--font-sans));
  font-weight: var(--is4-font-weight-bold, 800);
}

.card-title {
  font-size: var(--is4-font-size-title, 1.15rem);
}

.form-label {
  font-size: var(--is4-font-size-subtitle, 0.875rem);
  font-weight: var(--is4-font-weight-semibold, 600);
}

/* ── Botones ── */
.btn {
  padding: var(--is4-btn-pad, 0.6rem 1.2rem);
  font-weight: var(--is4-font-weight-semibold, 600);
  border-radius: var(--is4-radius-md, var(--radius-md));
  border-width: var(--is4-border-width, 1px);
}

.btn-primary,
.btn-blue {
  background-color: var(--is4-primary, var(--primary-green));
}

.btn-primary:hover,
.btn-blue:hover {
  background-color: var(--is4-primary-hover, var(--primary-green-hover));
}

.btn-secondary {
  background-color: var(--is4-surface, var(--bg-card));
  border-color: var(--is4-border, var(--border-color));
  color: var(--is4-text, var(--text-main));
}

.btn-secondary:hover {
  background-color: var(--is4-background, var(--bg-main));
}

.btn-danger {
  background-color: var(--is4-danger, var(--danger));
}

.btn-danger:hover {
  background-color: var(--is4-danger-hover, #dc2626);
}

.btn-sm {
  padding: calc(var(--is4-space-2, 8px) * 0.8) var(--is4-space-3, 14px);
}

/* ── Formularios ── */
.form-control {
  padding: var(--is4-input-pad, 0.625rem 0.875rem);
  font-family: var(--is4-font-family-form, var(--is4-font-family, var(--font-sans)));
  font-size: var(--is4-font-size-base, 14px);
  font-weight: var(--is4-font-weight-normal, 400);
  color: var(--is4-text, var(--text-main));
  background-color: var(--is4-surface, var(--bg-card));
  border: var(--is4-border-width, 1px) solid var(--is4-border, var(--border-color));
  border-radius: var(--is4-radius-md, var(--radius-md));
}

.form-control::placeholder {
  color: var(--is4-text-secondary, var(--text-muted));
}

.form-control:focus {
  border-color: var(--is4-accent, var(--primary-green));
  box-shadow: 0 0 0 3px var(--is4-sg-accent-soft, rgba(16, 185, 129, 0.15));
}

select.form-control,
.form-control select {
  background-color: var(--is4-surface, var(--bg-card));
  color: var(--is4-text, var(--text-main));
}

.icon-btn {
  background: var(--is4-surface, var(--bg-card));
  border: var(--is4-border-width, 1px) solid var(--is4-border, var(--border-color));
  color: var(--is4-icon, var(--text-main));
}

/* ── Cards / Paneles ── */
.card {
  background: var(--is4-surface, var(--bg-card));
  border: var(--is4-border-width, 1px) solid var(--is4-border, var(--border-color));
  border-radius: var(--is4-radius-lg, var(--radius-lg));
  padding: var(--is4-card-pad, 1.5rem);
}

/* ── Sidebar / menú ── */
.sidebar {
  background-color: var(--is4-sidebar-bg, var(--bg-sidebar));
}

.menu-item {
  padding: 0.45rem 0.6rem;
  font-size: 0.8rem;
  font-weight: var(--is4-font-weight-medium, 600);
  color: var(--is4-sidebar-muted, rgba(255, 255, 255, 0.78));
}

.menu-item:hover {
  color: var(--is4-sidebar-text, var(--text-white));
  background-color: var(--is4-sidebar-hover, rgba(255, 255, 255, 0.08));
}

.menu-item.active {
  color: var(--is4-sidebar-active-text, var(--text-white));
  background-color: var(--is4-sidebar-active-bg, var(--primary-green));
}

.menu-group-header {
  padding: 0.45rem 0.6rem;
  font-size: 0.8rem;
  font-weight: var(--is4-font-weight-medium, 700);
  color: var(--is4-sidebar-muted, rgba(255, 255, 255, 0.78));
}

.menu-group-header:hover {
  color: var(--is4-sidebar-text, var(--text-white));
  background-color: var(--is4-sidebar-hover, rgba(255, 255, 255, 0.08));
}

/* ── Iconos del menú ──
   Consumen --is4-sidebar-icon (emitido por applyTheme para los temas no-originales).
   En is4-original la variable NO se emite, por lo que cada icono conserva su color
   original multicolor mediante el fallback inline en app.js (var(--is4-sidebar-icon, #color)). */
.menu-item svg,
.menu-group-header svg.menu-icon {
  stroke: var(--is4-sidebar-icon, currentColor);
}

/* ── Header / top bar ── */
.top-bar {
  background: var(--is4-header-bg, var(--bg-card));
  border-bottom: 1px solid var(--is4-header-border, var(--border-color));
}

/* ── Smart Grids (solo variables de apariencia; NO toca lógica) ── */
.is4-sg {
  --sg-bg: var(--is4-surface, #ffffff);
  --sg-border: var(--is4-border, #e2e8f0);
  --sg-text: var(--is4-text, #1e293b);
  --sg-muted: var(--is4-text-secondary, #64748b);
  --sg-head-bg: var(--is4-sg-head-bg, #f8fafc);
  --sg-head-text: var(--is4-sg-head-text, #334155);
  --sg-row-hover: var(--is4-sg-row-hover, #f1f5f9);
  --sg-accent: var(--is4-sg-accent, var(--primary-blue));
  --sg-accent-soft: var(--is4-sg-accent-soft, #e6f4ea);
  --sg-sorted: var(--is4-sg-accent-soft, #f0fdf4);
  --sg-input-bg: var(--is4-surface, #ffffff);
  border-radius: var(--is4-radius-lg, var(--radius-lg));
}

.is4-sg-td,
.is4-sg-th-inner {
  font-size: var(--is4-font-size-grid, 0.85rem);
}

.is4-sg-row {
  padding: 0;
}

.is4-sg-row td {
  padding: var(--is4-row-pad, 0.6rem 1rem);
}

.is4-sg-page-btn,
.is4-sg-btn {
  font-weight: var(--is4-font-weight-medium, 500);
}

/* ── Modales (is4-dialog) ── */
.is4-dialog-card {
  background: var(--is4-surface, var(--bg-card));
  border: var(--is4-border-width, 1px) solid var(--is4-border, var(--border-color));
  border-radius: var(--is4-radius-lg, var(--radius-lg));
  font-family: var(--is4-font-family, var(--font-sans));
}

.is4-dialog-title {
  font-family: var(--is4-font-family-heading, var(--font-sans));
  font-weight: var(--is4-font-weight-bold, 800);
}

.is4-dialog-input {
  padding: var(--is4-input-pad, 0.5rem 0.75rem);
  border-radius: var(--is4-radius-md, var(--radius-md));
  border: var(--is4-border-width, 1px) solid var(--is4-border, var(--border-color));
}

.is4-dialog-btn-primary {
  background-color: var(--is4-primary, var(--primary-green));
}

.is4-dialog-btn-primary:hover {
  background-color: var(--is4-primary-hover, var(--primary-green-hover));
}

.is4-dialog-btn-danger {
  background-color: var(--is4-danger, var(--danger));
}

/* ── Notificaciones (is4-notify) ── */
.is4-notify {
  border-radius: var(--is4-radius-md, var(--radius-md));
}

.is4-notify-title {
  font-family: var(--is4-font-family-heading, var(--font-sans));
  font-weight: var(--is4-font-weight-semibold, 600);
}

.is4-notify.is4-type-success { --n-accent: var(--is4-success, #137333); --n-accent-bg: var(--is4-success-bg, #e6f4ea); --n-icon-color: var(--is4-success, #137333); }
.is4-notify.is4-type-error   { --n-accent: var(--is4-danger, #c5221f); --n-accent-bg: var(--is4-danger-bg, #fce8e6); --n-icon-color: var(--is4-danger, #c5221f); }
.is4-notify.is4-type-warning { --n-accent: var(--is4-warning, #b06000); --n-accent-bg: var(--is4-warning-bg, #fef7e0); --n-icon-color: var(--is4-warning, #b06000); }
.is4-notify.is4-type-info    { --n-accent: var(--is4-info, #1a73e8); --n-accent-bg: var(--is4-info-bg, #eff6ff); --n-icon-color: var(--is4-info, #1a73e8); }

/* ── Badges / estados (mantienen semántica) ── */
.badge-success {
  background: var(--is4-success-bg, rgba(16, 185, 129, 0.1));
  color: var(--is4-success, var(--success));
}

.badge-warning {
  background: var(--is4-warning-bg, rgba(245, 158, 11, 0.1));
  color: var(--is4-warning, var(--warning));
}

.badge-danger {
  background: var(--is4-danger-bg, rgba(239, 68, 68, 0.1));
  color: var(--is4-danger, var(--danger));
}

.badge-info {
  background: var(--is4-info-bg, rgba(37, 99, 235, 0.1));
  color: var(--is4-info, var(--info));
}

.badge-neutral {
  background: var(--is4-neutral, rgba(100, 116, 139, 0.1));
  color: var(--is4-neutral, var(--neutral));
}

/* ── Densidad visual (consume --is4-* emitidas por el tema) ── */
html[data-is4-density='compact'] .card {
  padding: var(--is4-card-pad, 14px);
}

html[data-is4-density='compact'] .form-group {
  margin-bottom: 0.75rem;
}

html[data-is4-density='compact'] .content-wrapper {
  padding: 1rem;
}

html[data-is4-density='comfortable'] .card {
  padding: var(--is4-card-pad, 26px);
}

html[data-is4-density='comfortable'] .form-group {
  margin-bottom: 1.5rem;
}

html[data-is4-density='comfortable'] .content-wrapper {
  padding: 1.75rem;
}

/* Scrollbar hereda la identidad del tema */
::-webkit-scrollbar-thumb {
  background: var(--is4-primary, var(--primary-green));
  border-radius: var(--is4-radius-full, 9999px);
}

/* ═══════════════════════════════════════════════════════════════════════════
   TASK-010B-R2 — SISTEMA REAL DE TEMAS VISUALES
   Extiende la capa R1 con identidad tipográfica, formas por componente
   (botón/card/input/modal/badge), sombras, espaciado y densidad granular.
   Todos los fallbacks mantienen el aspecto IS4 Original actual.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Identidad corporativa IS4 (fija, nunca se rompe con el tema) ── */
.brand-icon {
  background: #ffffff;
  color: #064e3b;
  border-radius: var(--is4-radius-sm, 4px);
  flex-shrink: 0;
}

.brand-name {
  color: #ffffff;
}

.brand-name span {
  color: #ffffff;
}

.sidebar-header {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

/* ── Tipografía: encabezados / etiquetas / badges según tema ── */
h1, h2, h3, h4, h5, h6,
.card-title,
.is4-sg-title {
  text-transform: var(--is4-heading-transform, none);
  letter-spacing: var(--is4-heading-letter-spacing, 0px);
}

.form-label,
.bst-btn,
.is4-sg-th-inner,
label {
  text-transform: var(--is4-label-transform, uppercase);
}

.badge,
.badge-success,
.badge-warning,
.badge-danger,
.badge-info,
.badge-neutral {
  text-transform: var(--is4-badge-transform, uppercase);
  font-weight: var(--is4-badge-weight, 700);
}

/* ── Botones: forma, sombra y estados según tema ── */
.btn {
  border-radius: var(--is4-button-radius, var(--radius-md));
  box-shadow: var(--is4-shadow-sm, none);
  transition: all 0.2s ease;
  font-family: var(--is4-font-family, var(--font-sans));
}

.btn:hover {
  box-shadow: var(--is4-shadow, none);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
  box-shadow: var(--is4-shadow-sm, none);
}

.btn-primary {
  box-shadow: var(--is4-shadow, var(--shadow));
}

/* ── Cards: radio, sombra y elevación según tema ── */
.card {
  border-radius: var(--is4-card-radius, var(--radius-lg));
  box-shadow: var(--is4-shadow, var(--shadow));
  border-width: var(--is4-border-width, 1px);
  font-family: var(--is4-font-family-dashboard, var(--is4-font-family, var(--font-sans)));
}

.card:hover {
  box-shadow: var(--is4-shadow, var(--shadow));
}

/* ── Inputs y formularios: forma y foco según tema ── */
.form-control,
.custom-select-trigger,
.search-select-dropdown,
.bank-select-trigger {
  border-radius: var(--is4-input-radius, var(--radius-md));
  border-width: var(--is4-border-width, 1px);
}

.form-control:focus {
  border-color: var(--is4-accent, var(--primary-green));
  box-shadow: 0 0 0 3px var(--is4-sg-accent-soft, rgba(16, 185, 129, 0.15));
}

/* ── Header: texto y sombra del tema ── */
.top-bar {
  color: var(--is4-header-text, var(--text-main));
}

/* ── Sidebar: separadores, item activo e indicador ── */
.sidebar-footer {
  border-top-color: rgba(255, 255, 255, 0.08);
}

.menu-item.active {
  box-shadow: var(--is4-shadow, var(--shadow));
  position: relative;
}

.menu-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 3px;
  background: var(--is4-sidebar-active-text, #ffffff);
}

/* ── Modales: radio y sombra fuerte del tema ── */
.modal-content,
.is4-dialog-card,
#bill-search-modal > div {
  border-radius: var(--is4-modal-radius, var(--radius-lg));
  box-shadow: var(--is4-shadow-strong, var(--shadow-lg));
}

/* ── Tablas / smart grid: radio del tema ── */
.is4-sg,
.table-container {
  border-radius: var(--is4-table-radius, var(--radius-lg));
  overflow: hidden;
}

/* ── Espaciado granular del tema ── */
.menu-item,
.menu-group-header {
  padding-left: 0.6rem;
  padding-right: 0.6rem;
  gap: 0.5rem;
}

.card-header-flex {
  gap: var(--is4-spacing-md, 1rem);
}

/* ── Densidad granular: botones, grids, forms según data-is4-density ── */
html[data-is4-density='compact'] .form-row,
html[data-is4-density='compact'] .settings-grid {
  gap: 0.75rem;
}

html[data-is4-density='compact'] .is4-sg-row td {
  padding: 4px 10px;
}

html[data-is4-density='compact'] .form-control {
  padding: 0.4rem 0.6rem;
  font-size: var(--is4-font-size-small, 12px);
}

html[data-is4-density='compact'] .btn {
  padding: 0.4rem 0.9rem;
  font-size: var(--is4-font-size-small, 12px);
}

html[data-is4-density='standard'] .form-row,
html[data-is4-density='standard'] .settings-grid {
  gap: 1.25rem;
}

html[data-is4-density='comfortable'] .form-row,
html[data-is4-density='comfortable'] .settings-grid {
  gap: 2rem;
}

html[data-is4-density='comfortable'] .is4-sg-row td {
  padding: 0.85rem 1.25rem;
}

html[data-is4-density='comfortable'] .form-control {
  padding: 0.8rem 1rem;
}

html[data-is4-density='comfortable'] .btn {
  padding: 0.8rem 1.6rem;
}

/* ── Modo oscuro del tema: fondos y bordes heredados ── */
body[data-theme='dark'] .top-bar {
  border-bottom-color: var(--is4-header-border, var(--border));
}

/* Transición suave al cambiar de tema */
body,
.sidebar,
.top-bar,
.card,
.btn,
.form-control {
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease, border-radius 0.25s ease, box-shadow 0.25s ease;
}

/* ── TASK-023: Identidad Visual Global (Branding del Sistema) ── */
.btn-color-preset {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-color-preset:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.btn-color-preset:active {
  transform: translateY(0);
}
#sim-header-box {
  transition: background-color 0.25s ease;
}
.branding-catalog-card {
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.branding-catalog-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px -1px rgba(0,0,0,0.08);
}

/* ── TASK-MASTER-002: Contenedor Responsivo Universal para Tablas y Grids ── */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 70vh;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--is4-table-radius, var(--radius-lg));
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.table-responsive::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.table-responsive::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.02);
}

.table-responsive::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.7);
}

.table-responsive table {
  width: 100%;
  min-width: 650px;
  border-collapse: collapse;
}

.table-responsive table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #f8fafc;
  box-shadow: 0 1px 0 #e2e8f0;
}

/* ── Botón de Ayuda Contextual en Encabezados ── */
.is4-view-help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #0284c7;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  vertical-align: middle;
  padding: 0;
  line-height: 1;
}

.is4-view-help-btn:hover {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
  transform: scale(1.1);
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3);
}

.is4-view-help-btn:active {
  transform: scale(0.95);
}

/* ── TASK-MASTER-004: Enrutamiento OCR, Action Chips y unmappedFields en IS4 AI Copilot ── */
.is4-ai-ocr-routing-card {
  transition: all 0.25s ease;
}

.is4-ai-chip-btn {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.is4-ai-chip-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.is4-ai-chip-btn:active {
  transform: translateY(0) scale(0.97);
}

.is4-ai-chip-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.is4-ai-unmapped-row {
  transition: background 0.15s ease;
}

.is4-ai-unmapped-row:hover {
  background: rgba(30, 41, 59, 0.9) !important;
}

.btn-is4-ai-bind-field {
  transition: all 0.15s ease;
}

.btn-is4-ai-bind-field:hover {
  filter: brightness(1.2);
  transform: scale(1.05);
}

.is4-ai-input-required-warn {
  border-color: #fbbf24 !important;
  background: rgba(245, 158, 11, 0.08) !important;
  animation: pulseWarn 2s infinite ease-in-out;
}

@keyframes pulseWarn {
  0%, 100% { border-color: rgba(245, 158, 11, 0.5); }
  50% { border-color: rgba(245, 158, 11, 1); box-shadow: 0 0 6px rgba(245, 158, 11, 0.4); }
}
