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

:root {
  --bg-body: #f0f2f5;
  --bg-sidebar: #1a1d29;
  --bg-topbar: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f8f9fa;
  --text-primary: #1a1d29;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --text-sidebar: #a0aec0;
  --text-sidebar-hover: #ffffff;
  --border-color: #e5e7eb;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-light: #eef2ff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --gradient-primary: linear-gradient(135deg, #6366f1, #8b5cf6);
  --gradient-success: linear-gradient(135deg, #10b981, #34d399);
  --gradient-warning: linear-gradient(135deg, #f59e0b, #fbbf24);
  --gradient-danger: linear-gradient(135deg, #ef4444, #f87171);
  --gradient-info: linear-gradient(135deg, #3b82f6, #60a5fa);
  --sidebar-width: 260px;
  --topbar-height: 64px;
}

[data-theme="dark"] {
  --bg-body: #0f1117;
  --bg-sidebar: #161822;
  --bg-topbar: #1a1d29;
  --bg-card: #1e2030;
  --bg-input: #252838;
  --text-primary: #e5e7eb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --border-color: #2d3040;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
  --accent-light: #1e1b4b;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

.app-wrapper {
  display: flex;
  min-height: 100vh;
  transition: padding-left 0.3s ease;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  z-index: 1040;
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand .brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
}

.sidebar-brand span {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.sidebar-close-btn {
  display: none;
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-sidebar);
  font-size: 20px;
  cursor: pointer;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.3);
  padding: 20px 12px 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-sidebar);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  margin-bottom: 2px;
  position: relative;
}

.nav-link:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-sidebar-hover);
}

.nav-link.active {
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: 0 4px 15px rgba(99,102,241,0.3);
}

.nav-link.nav-link-danger:hover {
  background: rgba(239,68,68,0.15);
  color: var(--danger);
}

.nav-icon {
  width: 20px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}

.nav-label { flex: 1; }

.nav-badge {
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  min-width: 22px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1035;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 24px 32px;
  padding-top: calc(var(--topbar-height) + 24px);
  transition: margin-left 0.3s ease;
  min-width: 0;
}

.top-navbar {
  position: fixed;
  top: 0;
  right: 0;
  left: var(--sidebar-width);
  height: var(--topbar-height);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1030;
  transition: left 0.3s ease;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.85);
}

[data-theme="dark"] .top-navbar {
  background: rgba(26, 29, 41, 0.85);
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sidebar-toggle {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: all 0.2s;
  display: none;
}

.sidebar-toggle:hover { background: var(--bg-input); }

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo .brand-icon {
  display: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--gradient-primary);
  display: none;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.navbar-center { flex: 1; max-width: 400px; margin: 0 24px; }

.global-search-wrap {
  position: relative;
  width: 100%;
}

.global-search {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

.global-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.global-search-wrap .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 1050;
  max-height: 320px;
  overflow-y: auto;
}

.search-results.show { display: block; }

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  transition: background 0.15s;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-input); }

.navbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  text-decoration: none;
}

.nav-icon-btn:hover { background: var(--bg-input); color: var(--text-primary); }

.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-dropdown .admin-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.admin-dropdown .admin-btn:hover { background: var(--bg-input); }
.admin-dropdown .admin-btn::after { display: none; }

.admin-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--gradient-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.admin-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.admin-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.admin-role { font-size: 11px; color: var(--text-muted); }

.glass-dropdown {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  background: var(--bg-card);
}

.glass-dropdown .dropdown-item {
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text-primary);
}

.glass-dropdown .dropdown-item:hover { background: var(--bg-input); }

.flash-toast {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 9999;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s ease;
  max-width: 420px;
}

.flash-toast.flash-success { background: #ecfdf5; color: #065f46; border-left: 4px solid var(--success); }
.flash-toast.flash-danger { background: #fef2f2; color: #991b1b; border-left: 4px solid var(--danger); }
.flash-toast.flash-info { background: #eff6ff; color: #1e40af; border-left: 4px solid var(--info); }

[data-theme="dark"] .flash-toast.flash-success { background: #064e3b; color: #a7f3d0; }
[data-theme="dark"] .flash-toast.flash-danger { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .flash-toast.flash-info { background: #1e3a5f; color: #93c5fd; }

.flash-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.6;
  color: inherit;
}

.flash-toast.fade-out { animation: slideOutRight 0.3s ease forwards; }

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

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

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.spinner-ring {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-color);
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.page-title i { color: var(--accent); margin-right: 10px; }

.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

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

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h5 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

.card-body { padding: 20px; }

.stat-card {
  padding: 20px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
  transition: all 0.3s;
}

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

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 14px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-icon.primary { background: var(--accent-light); color: var(--accent); }
.stat-icon.success { background: #ecfdf5; color: var(--success); }
.stat-icon.warning { background: #fffbeb; color: var(--warning); }
.stat-icon.danger { background: #fef2f2; color: var(--danger); }
.stat-icon.info { background: #eff6ff; color: var(--info); }

[data-theme="dark"] .stat-icon.success { background: #064e3b; }
[data-theme="dark"] .stat-icon.warning { background: #78350f; }
[data-theme="dark"] .stat-icon.danger { background: #7f1d1d; }
[data-theme="dark"] .stat-icon.info { background: #1e3a5f; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-active { background: #ecfdf5; color: #065f46; }
.badge-inactive { background: #fef2f2; color: #991b1b; }
.badge-paid { background: #ecfdf5; color: #065f46; }
.badge-partial { background: #fffbeb; color: #92400e; }
.badge-pending { background: #fef2f2; color: #991b1b; }
.badge-secondary { background: var(--bg-input); color: var(--text-secondary); }
.badge-ontrack { background: #ecfdf5; color: #065f46; }
.badge-below { background: #fffbeb; color: #92400e; }
.badge-overdue { background: #fef2f2; color: #991b1b; }

[data-theme="dark"] .badge-active { background: #064e3b; color: #a7f3d0; }
[data-theme="dark"] .badge-inactive { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .badge-paid { background: #064e3b; color: #a7f3d0; }
[data-theme="dark"] .badge-partial { background: #78350f; color: #fde68a; }
[data-theme="dark"] .badge-pending { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .badge-ontrack { background: #064e3b; color: #a7f3d0; }
[data-theme="dark"] .badge-below { background: #78350f; color: #fde68a; }
[data-theme="dark"] .badge-overdue { background: #7f1d1d; color: #fca5a5; }

.table-custom {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table-custom th {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-color);
  background: transparent;
}

.table-custom td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  color: var(--text-primary);
}

.table-custom tr:hover td { background: var(--bg-input); }

.table-custom .client-info {
  display: flex;
  flex-direction: column;
}

.table-custom .client-info .name {
  font-weight: 600;
  color: var(--text-primary);
}

.table-custom .client-info .business {
  font-size: 12px;
  color: var(--text-secondary);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99,102,241,0.25);
}

.btn-primary:hover { box-shadow: 0 4px 16px rgba(99,102,241,0.4); transform: translateY(-1px); }

.btn-success { background: var(--gradient-success); color: #fff; }
.btn-success:hover { box-shadow: 0 4px 16px rgba(16,185,129,0.4); transform: translateY(-1px); }

.btn-warning { background: var(--gradient-warning); color: #fff; }
.btn-warning:hover { box-shadow: 0 4px 16px rgba(245,158,11,0.4); transform: translateY(-1px); }

.btn-danger { background: var(--gradient-danger); color: #fff; }
.btn-danger:hover { box-shadow: 0 4px 16px rgba(239,68,68,0.4); transform: translateY(-1px); }

.btn-info { background: var(--gradient-info); color: #fff; }
.btn-info:hover { box-shadow: 0 4px 16px rgba(59,130,246,0.4); transform: translateY(-1px); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-outline:hover { background: var(--bg-input); border-color: var(--accent); color: var(--accent); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11px; }

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control, .form-select {
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  width: 100%;
  outline: none;
  transition: all 0.2s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

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

textarea.form-control { resize: vertical; min-height: 80px; }

select.form-select { cursor: pointer; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.form-group { margin-bottom: 16px; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h5 { font-size: 18px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 14px; max-width: 400px; margin: 0 auto 20px; }

.pagination-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 0;
}

.page-link-custom {
  padding: 8px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.page-link-custom:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-link-custom.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-link-custom.disabled { opacity: 0.4; pointer-events: none; }

.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-bar .form-control,
.filter-bar .form-select { width: auto; min-width: 180px; }

.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.activity-item:last-child { border-bottom: none; }

.activity-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.activity-icon.client { background: var(--accent-light); color: var(--accent); }
.activity-icon.payment { background: #ecfdf5; color: var(--success); }
.activity-icon.service { background: #fffbeb; color: var(--warning); }

[data-theme="dark"] .activity-icon.payment { background: #064e3b; }
[data-theme="dark"] .activity-icon.service { background: #78350f; }

.activity-content { flex: 1; }
.activity-text { font-size: 14px; color: var(--text-primary); }
.activity-time { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.detail-item {
  padding: 16px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

.detail-item .label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-item .value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-body);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .brand-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--gradient-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
  margin-bottom: 12px;
}

.login-logo h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
}

.login-logo p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; }
  .sidebar-toggle { display: flex; }
  .sidebar-close-btn { display: flex; }
  .main-content { margin-left: 0; padding: 20px 16px; padding-top: calc(var(--topbar-height) + 16px); }
  .top-navbar { left: 0; padding: 0 16px; }
  .brand-logo .brand-icon { display: flex; }
  .brand-name { display: none; }
  .navbar-center { display: none; }
  .page-title { font-size: 20px; }
  .stat-card .stat-value { font-size: 24px; }
  .form-row { grid-template-columns: 1fr; }
  .filter-bar .form-control, .filter-bar .form-select { width: 100%; }
}

@media (max-width: 575.98px) {
  .main-content { padding: 16px 12px; padding-top: calc(var(--topbar-height) + 12px); }
  .card-body { padding: 16px; }
  .login-card { padding: 24px; }
  .table-custom { font-size: 12px; }
  .table-custom th, .table-custom td { padding: 8px 8px; white-space: nowrap; }
  .filter-bar .btn { width: 100%; }
  .filter-bar a.btn { text-align: center; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header .btn { width: 100%; justify-content: center; }
  .btn, .btn-sm, .nav-link { min-height: 44px; }
  .nav-link { padding: 12px; }
  .sidebar { width: 280px; }
  .stat-card .stat-value { font-size: 20px; }
  .chart-container { height: 220px; }
  .stat-card.mini { padding: 8px 12px; }
  .stat-card.mini .stat-value { font-size: 16px; }
  .feed-item { flex-direction: column; gap: 8px; }
  .dash-mini-stat { padding: 6px 2px; }
  .dms-value { font-size: 16px; }
  .activity-item { padding: 10px 0; }
  .card-header { padding: 12px 16px; }
  .card-header h5 { font-size: 14px; }
}

.modal-content-custom {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.modal-header-custom {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.btn-whatsapp {
  background: linear-gradient(135deg, #25d366, #128c7e);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.25);
}

.btn-whatsapp:hover {
  box-shadow: 0 4px 16px rgba(37, 211, 102, 0.4);
  transform: translateY(-1px);
  color: #fff;
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Feature Toggle ─────────────────────────────── */
#featureToggle {
  cursor: pointer;
}
#featureToggle:checked {
  background-color: var(--success);
  border-color: var(--success);
}

/* ── Activity Feed ─────────────────────────────────────── */
.activity-feed {
  padding: 16px 20px;
}

.feed-date-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.feed-date-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.feed-item {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-color);
  animation: fadeIn 0.3s ease both;
}

.feed-item:last-child {
  border-bottom: none;
}

.feed-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

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

.feed-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.feed-role {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 1px 8px;
  border-radius: 10px;
}

.feed-time {
  font-size: 11px;
  color: var(--text-muted);
}

.feed-work {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: 6px;
}

.feed-time-badge {
  display: inline-block;
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-light);
  padding: 1px 10px;
  border-radius: 10px;
  margin-left: 8px;
}

.feed-client,
.feed-pending,
.feed-delay,
.feed-link,
.feed-notes {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.feed-pending {
  color: var(--warning);
}

.feed-delay {
  color: var(--danger);
}

.feed-link a {
  color: var(--info);
  word-break: break-all;
}

.status-badge-xs {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
}

.feed-actions {
  display: flex;
  gap: 4px;
}

.feed-locked {
  opacity: 0.7;
}

.feed-updated {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.feed-updated i {
  margin-right: 4px;
}

.stat-card.mini {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
}

.stat-card.mini .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.stat-card.mini .stat-info {
  flex: 1;
}

.stat-card.mini .stat-value {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
}

.stat-card.mini .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.stat-card { animation: fadeInUp 0.5s ease both; }
.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }

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

.card { animation: fadeIn 0.4s ease both; }

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

/* ── Timeline Cards ───────────────────────────────────── */
.timeline-card {
  display: flex;
  gap: 18px;
  padding: 18px 22px;
  position: relative;
  transition: all 0.25s ease;
  animation: fadeIn 0.35s ease both;
}

.timeline-card + .timeline-card {
  border-top: 1px solid var(--border-color);
}

.timeline-card:hover {
  background: var(--bg-body);
  padding-left: 26px;
}

[data-theme="dark"] .timeline-card:hover {
  background: rgba(255,255,255,0.02);
}

.timeline-line {
  position: absolute;
  left: 39px;
  top: 54px;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--accent), transparent 80%);
  opacity: 0.25;
}

.timeline-card:last-child .timeline-line {
  display: none;
}

.timeline-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  box-shadow: 0 3px 10px rgba(0,0,0,0.12);
}

.timeline-body {
  flex: 1;
  min-width: 0;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

.timeline-card:hover .timeline-body {
  box-shadow: var(--shadow-md);
}

.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.timeline-user {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.timeline-user strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.timeline-role {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 2px 10px;
  border-radius: 10px;
  font-weight: 500;
}

.timeline-time {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.timeline-badges {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-shrink: 0;
}

.timeline-badges .badge {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 10px;
  letter-spacing: 0.2px;
}

.timeline-edited {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.timeline-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.timeline-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-input);
  padding: 3px 10px;
  border-radius: 8px;
  font-weight: 500;
}

.timeline-meta span i {
  color: var(--accent);
  font-size: 11px;
}

.timeline-work {
  margin-bottom: 4px;
}

.work-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--success);
  margin-bottom: 4px;
}

.work-text {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.65;
  padding: 6px 10px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

.timeline-pending {
  margin: 8px 0;
  padding: 10px 12px;
  background: rgba(245,158,11,0.08);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--warning);
}

[data-theme="dark"] .timeline-pending {
  background: rgba(245,158,11,0.12);
}

.pending-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--warning);
  margin-bottom: 3px;
}

.pending-text {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
}

.timeline-delay {
  font-size: 13px;
  color: var(--danger);
  margin: 6px 0;
  padding: 6px 10px;
  background: rgba(239,68,68,0.06);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--danger);
}

[data-theme="dark"] .timeline-delay {
  background: rgba(239,68,68,0.12);
}

.timeline-expected {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 4px 0;
  padding: 5px 10px;
  background: var(--bg-input);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}

.timeline-expected.overdue {
  color: var(--danger);
  background: rgba(239,68,68,0.08);
  font-weight: 600;
}

[data-theme="dark"] .timeline-expected.overdue {
  background: rgba(239,68,68,0.18);
}

.timeline-link {
  font-size: 13px;
  margin: 6px 0;
}

.timeline-link a {
  color: var(--info);
  font-weight: 500;
  text-decoration: none;
}

.timeline-link a:hover {
  text-decoration: underline;
}

.timeline-notes {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 6px 0;
  padding: 5px 10px;
  background: var(--bg-input);
  border-radius: 8px;
  font-style: italic;
}

.timeline-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.timeline-actions .btn {
  font-size: 12px;
  padding: 3px 12px;
  border-radius: 8px;
}

/* ── Priority Badges ──────────────────────────────────── */
.priority-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.priority-high {
  background: rgba(239,68,68,0.12);
  color: #ef4444;
}

.priority-medium {
  background: rgba(245,158,11,0.12);
  color: #f59e0b;
}

.priority-low {
  background: rgba(16,185,129,0.12);
  color: #10b981;
}

[data-theme="dark"] .priority-high { background: rgba(239,68,68,0.25); }
[data-theme="dark"] .priority-medium { background: rgba(245,158,11,0.25); }
[data-theme="dark"] .priority-low { background: rgba(16,185,129,0.25); }

/* ── Feed Date Separator ──────────────────────────────── */
.feed-date-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.feed-date-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border-color), transparent);
}

/* ── Dashboard Mini Stats ─────────────────────────────── */
.dash-mini-stat {
  text-align: center;
  padding: 8px 4px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  transition: transform 0.2s;
}

.dash-mini-stat:hover {
  transform: translateY(-2px);
}

.dms-value {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
}

.dms-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 2px;
}

/* ── Dashboard Productivity ───────────────────────────── */
.dash-productivity {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.prod-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

.prod-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.prod-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ── Modal Glass Effect ───────────────────────────────── */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
}

.modal-content {
  border: none;
  box-shadow: var(--shadow-lg);
}

/* ── Conditional Fields Animation ─────────────────────── */
.conditional-pending,
.conditional-delay {
  transition: all 0.3s ease;
}

/* ── Stat Card Mini responsive tweaks ─────────────────── */
@media (max-width: 768px) {
  .stat-card.mini {
    padding: 10px 12px;
  }
  .stat-card.mini .stat-value {
    font-size: 18px;
  }
  .timeline-meta {
    flex-direction: column;
    gap: 4px;
  }
  .timeline-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .timeline-badges {
    margin-top: 4px;
  }
}
