/* ==========================================================================
   AutoPoster — LinkedIn Auto-Poster Dashboard
   Modern SaaS design language
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */
:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --primary: #0a66c2;
  --primary-soft: rgba(10, 102, 194, 0.1);
  --gradient: linear-gradient(135deg, #0a66c2, #0e8de0);
  --ink: #0f172a;
  --muted: #64748b;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --border: #e2e8f0;
  --sidebar-width: 250px;
  --sidebar-bg: linear-gradient(180deg, #0b1524 0%, #101d33 100%);
  --shadow-sm: 0 1px 3px rgb(15 23 42 / 0.08);
  --shadow-md: 0 6px 18px rgb(15 23 42 / 0.1);
  --shadow-lg: 0 14px 34px rgb(15 23 42 / 0.14);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: 180ms ease;
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg);
  color: var(--ink);
  font-size: 0.9375rem;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
}

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

a:hover {
  color: #084d94;
}

::selection {
  background: rgba(10, 102, 194, 0.18);
}

/* Custom scrollbar — thin, slate */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 8px;
}

::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

* {
  scrollbar-width: thin;
  scrollbar-color: #94a3b8 transparent;
}

/* --------------------------------------------------------------------------
   3. Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  z-index: 1040;
  overflow-y: auto;
  transition: transform 250ms ease;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.05);
}

.sidebar .sidebar-brand,
.sidebar .navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: #ffffff;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  padding: 0.35rem 0.75rem 1.1rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-decoration: none;
}

.sidebar .sidebar-brand i,
.sidebar .navbar-brand i {
  font-size: 1.35rem;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 10px rgba(14, 141, 224, 0.45));
}

.sidebar .nav,
.sidebar .sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar .nav-link,
.sidebar .sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #94a3b8;
  font-weight: 500;
  font-size: 0.925rem;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition),
    transform var(--transition);
}

.sidebar .nav-link i,
.sidebar .sidebar-link i {
  font-size: 1.05rem;
  width: 1.35rem;
  text-align: center;
  flex-shrink: 0;
  transition: transform var(--transition);
}

.sidebar .nav-link:hover,
.sidebar .sidebar-link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
  transform: translateX(2px);
}

.sidebar .nav-link:hover i,
.sidebar .sidebar-link:hover i {
  transform: scale(1.1);
}

.sidebar .nav-link.active,
.sidebar .sidebar-link.active {
  color: #ffffff;
  background: var(--gradient);
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(10, 102, 194, 0.4);
}

.sidebar .nav-link.active:hover,
.sidebar .sidebar-link.active:hover {
  transform: none;
}

.sidebar .nav-link:focus-visible,
.sidebar .sidebar-link:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.sidebar .sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.sidebar .sidebar-footer .sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #cbd5e1;
  font-size: 0.875rem;
  font-weight: 500;
  min-width: 0;
}

.sidebar .sidebar-footer .sidebar-user i {
  font-size: 1.3rem;
  color: #64748b;
}

.sidebar .sidebar-footer .sidebar-user span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar .sidebar-footer form {
  margin: 0;
}

.sidebar .sidebar-footer button,
.sidebar .sidebar-logout-btn,
.sidebar .btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  border-radius: var(--radius-sm);
  padding: 0.42rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition),
    border-color var(--transition);
}

.sidebar .sidebar-footer button:hover,
.sidebar .sidebar-logout-btn:hover,
.sidebar .btn-logout:hover {
  background: rgba(220, 38, 38, 0.18);
  color: #fca5a5;
  border-color: rgba(220, 38, 38, 0.3);
}

.sidebar .sidebar-footer button:focus-visible,
.sidebar .sidebar-logout-btn:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   4. Main content area
   -------------------------------------------------------------------------- */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 2rem 2.25rem 3rem;
  min-height: 100vh;
  transition: margin-left 250ms ease;
}

/* Mobile hamburger */
#sidebarToggle {
  display: none;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 0.9rem;
  left: 0.9rem;
  z-index: 1050;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 1.2rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}

#sidebarToggle:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Overlay behind off-canvas sidebar */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  z-index: 1035;
  opacity: 0;
  visibility: hidden;
  transition: opacity 250ms ease, visibility 250ms ease;
}

/* --------------------------------------------------------------------------
   5. Page header
   -------------------------------------------------------------------------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.page-header h1 {
  font-size: 1.55rem;
  font-weight: 800;
  margin: 0;
}

.page-header .page-subtitle,
.page-header p {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.15rem 0 0;
}

.page-header .page-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   6. Cards & panels
   -------------------------------------------------------------------------- */
.card-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: box-shadow var(--transition);
  animation: fade-up 420ms cubic-bezier(0.22, 0.9, 0.3, 1) backwards;
}

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

.card-panel > h2,
.card-panel > h3,
.card-panel .panel-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.card-panel .panel-title i,
.card-panel h2 i,
.card-panel h3 i {
  color: var(--primary);
}

.card-panel h2.text-danger i,
.card-panel h3.text-danger i {
  color: var(--danger);
}

/* Entrance animation — cards fade & rise in with a soft stagger */
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-header {
  animation: fade-up 360ms cubic-bezier(0.22, 0.9, 0.3, 1) backwards;
}

.stat-card {
  animation: fade-up 420ms cubic-bezier(0.22, 0.9, 0.3, 1) backwards;
}

.stat-cards .stat-card:nth-child(1),
.stats-grid .stat-card:nth-child(1) { animation-delay: 40ms; }
.stat-cards .stat-card:nth-child(2),
.stats-grid .stat-card:nth-child(2) { animation-delay: 100ms; }
.stat-cards .stat-card:nth-child(3),
.stats-grid .stat-card:nth-child(3) { animation-delay: 160ms; }
.stat-cards .stat-card:nth-child(4),
.stats-grid .stat-card:nth-child(4) { animation-delay: 220ms; }

.main-content > * > .card-panel:nth-of-type(1),
.main-content > .card-panel:nth-of-type(1) { animation-delay: 120ms; }
.main-content > * > .card-panel:nth-of-type(2),
.main-content > .card-panel:nth-of-type(2) { animation-delay: 200ms; }
.main-content > * > .card-panel:nth-of-type(3),
.main-content > .card-panel:nth-of-type(3) { animation-delay: 280ms; }

/* Stat cards */
.stat-cards,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.35rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient);
  opacity: 0;
  transition: opacity var(--transition);
}

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

.stat-card:hover::after {
  opacity: 1;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.stat-card .stat-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
  background: var(--primary-soft);
  color: var(--primary);
  transition: transform var(--transition);
}

.stat-card:hover .stat-card-icon {
  transform: scale(1.08);
}

.stat-card-icon.icon-success,
.stat-card-icon.text-success {
  background: rgba(22, 163, 74, 0.12);
  color: var(--success);
}

.stat-card-icon.icon-danger,
.stat-card-icon.text-danger {
  background: rgba(220, 38, 38, 0.12);
  color: var(--danger);
}

.stat-card-icon.icon-warning,
.stat-card-icon.text-warning {
  background: rgba(217, 119, 6, 0.12);
  color: var(--warning);
}

.stat-card-icon.icon-primary,
.stat-card-icon.text-primary {
  background: var(--primary-soft);
  color: var(--primary);
}

/* --------------------------------------------------------------------------
   7. Status dots
   -------------------------------------------------------------------------- */
.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cbd5e1;
  margin-right: 0.4rem;
  vertical-align: middle;
  flex-shrink: 0;
}

.status-dot.on {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.18);
  animation: pulse-dot 2s ease-in-out infinite;
}

.status-dot.off {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.15);
}

@keyframes pulse-dot {
  0%, 100% {
    box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.18);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(22, 163, 74, 0.08);
  }
}

/* --------------------------------------------------------------------------
   8. Badges — pill, soft tints
   -------------------------------------------------------------------------- */
.badge-posted,
.badge-pending,
.badge-failed {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3em 0.85em;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-posted {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
  border: 1px solid rgba(22, 163, 74, 0.25);
}

.badge-pending {
  background: rgba(217, 119, 6, 0.12);
  color: #b45309;
  border: 1px solid rgba(217, 119, 6, 0.25);
}

.badge-failed {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
  border: 1px solid rgba(220, 38, 38, 0.25);
}

/* Neutral pill badges (run type chips etc.) */
.badge.text-bg-light {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: #f8fafc !important;
  color: #475569 !important;
  border-color: var(--border) !important;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.3em 0.85em;
  line-height: 1.4;
}

/* --------------------------------------------------------------------------
   9. Tables
   -------------------------------------------------------------------------- */
.table-clean {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0;
  background: transparent;
}

.table-clean thead th {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 0.7rem 0.9rem;
  white-space: nowrap;
}

.table-clean tbody td {
  padding: 0.85rem 0.9rem;
  border: none;
  border-bottom: 1px solid #eef2f7;
  vertical-align: middle;
  color: var(--ink);
  font-size: 0.9rem;
  background: transparent;
}

.table-clean tbody tr {
  transition: background var(--transition);
}

.table-clean tbody tr:hover {
  background: #f8fafc;
}

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

/* Table wrapper for horizontal overflow */
.table-responsive,
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
}

/* Row image thumbnail */
.row-image-thumb {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
  background: #f8fafc;
}

.row-image-thumb:hover {
  transform: scale(1.9);
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 5;
}

/* --------------------------------------------------------------------------
   10. Buttons
   -------------------------------------------------------------------------- */
.btn-gradient {
  background: var(--gradient);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  padding: 0.55rem 1.25rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 14px rgba(10, 102, 194, 0.35);
  transition: transform var(--transition), box-shadow var(--transition),
    filter var(--transition);
}

.btn-gradient:hover,
.btn-gradient:focus {
  color: #ffffff;
  filter: brightness(1.07);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(10, 102, 194, 0.45);
}

.btn-gradient:active {
  transform: translateY(0);
  box-shadow: 0 3px 10px rgba(10, 102, 194, 0.35);
}

.btn-gradient:disabled,
.btn-gradient.disabled {
  filter: grayscale(0.35);
  opacity: 0.7;
  box-shadow: none;
  transform: none;
  cursor: not-allowed;
}

.btn {
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: transform var(--transition), box-shadow var(--transition),
    background var(--transition), color var(--transition);
}

.btn-outline-secondary,
.btn-outline-primary,
.btn-outline-danger {
  border-radius: var(--radius-sm);
}

/* --------------------------------------------------------------------------
   11. Empty state
   -------------------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  background: #f8fafc80;
}

.empty-state i {
  font-size: 2.5rem;
  color: #94a3b8;
  display: block;
  margin-bottom: 0.75rem;
}

.empty-state .empty-title,
.empty-state h5,
.empty-state h6 {
  color: var(--ink);
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.35rem;
}

.empty-state p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.empty-state .btn {
  margin-top: 0.85rem;
}

/* --------------------------------------------------------------------------
   12. Flash / toast container
   -------------------------------------------------------------------------- */
.flash-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: min(400px, calc(100vw - 2.5rem));
  width: 100%;
  pointer-events: none;
}

.flash-container .alert {
  pointer-events: auto;
  border: none;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.85rem 2.5rem 0.85rem 1rem;
  margin: 0;
  animation: flash-in 280ms cubic-bezier(0.2, 0.9, 0.3, 1.1);
  border-left: 4px solid transparent;
}

.flash-container .alert-success {
  background: #f0fdf4;
  color: #166534;
  border-left-color: var(--success);
}

.flash-container .alert-danger,
.flash-container .alert-error {
  background: #fef2f2;
  color: #991b1b;
  border-left-color: var(--danger);
}

.flash-container .alert-warning {
  background: #fffbeb;
  color: #92400e;
  border-left-color: var(--warning);
}

.flash-container .alert-info {
  background: #eff6ff;
  color: #1e40af;
  border-left-color: var(--primary);
}

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

/* --------------------------------------------------------------------------
   13. Forms
   -------------------------------------------------------------------------- */
.form-control,
.form-select {
  border-radius: var(--radius-sm);
  border-color: var(--border);
  padding: 0.55rem 0.85rem;
  font-size: 0.925rem;
  color: var(--ink);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem rgba(10, 102, 194, 0.15);
}

.form-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: #334155;
  margin-bottom: 0.35rem;
}

.form-text {
  color: var(--muted);
  font-size: 0.8rem;
}

.form-check-input {
  border-color: #cbd5e1;
  cursor: pointer;
}

.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.form-check-input:focus {
  box-shadow: 0 0 0 0.2rem rgba(10, 102, 194, 0.15);
  border-color: var(--primary);
}

.form-switch .form-check-input {
  width: 2.6em;
  height: 1.4em;
  margin-top: 0.1em;
}

/* --------------------------------------------------------------------------
   14. Misc components
   -------------------------------------------------------------------------- */
/* Status panel rows on the dashboard */
.status-row,
.status-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid #eef2f7;
  font-size: 0.9rem;
}

.status-row:last-child,
.status-item:last-child {
  border-bottom: none;
}

.status-row .status-label,
.status-item .status-label {
  color: var(--muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

/* Countdown */
#countdown {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--primary);
}

/* Pagination */
.pagination {
  gap: 0.25rem;
}

.pagination .page-link {
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--border);
  color: var(--ink);
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.4rem 0.8rem;
  margin: 0;
  transition: background var(--transition), color var(--transition);
}

.pagination .page-link:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.pagination .page-item.active .page-link {
  background: var(--gradient);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(10, 102, 194, 0.35);
}

.pagination .page-item.disabled .page-link {
  color: #cbd5e1;
  background: transparent;
}

/* Alerts inside pages (non-flash) */
.alert {
  border-radius: var(--radius-sm);
}

/* Code / copyable inputs */
input[readonly].form-control {
  background: #f8fafc;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.82rem;
}

.copy-btn {
  white-space: nowrap;
}

/* Next-up preview text */
.next-up-text,
.post-preview-text {
  white-space: pre-wrap;
  word-break: break-word;
  color: #334155;
  font-size: 0.9rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
}

/* Legend chips (sheet preview) */
.legend {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.83rem;
  color: var(--muted);
}

/* Login page (standalone) */
.login-bg,
body.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0b1524 0%, #0a66c2 55%, #0e8de0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2.25rem 2rem;
  width: 100%;
  max-width: 400px;
  animation: flash-in 320ms ease;
}

.login-card .login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 1.5rem;
}

.login-card .login-brand i {
  color: var(--primary);
  font-size: 1.5rem;
}

/* Global keyboard focus ring */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
.form-check-input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn:focus-visible,
.btn-gradient:focus-visible {
  box-shadow: 0 0 0 0.2rem rgba(10, 102, 194, 0.25);
}

/* Utility */
.text-muted-2 {
  color: var(--muted) !important;
}

.fw-650 {
  font-weight: 650;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mono {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.83em;
}

/* --------------------------------------------------------------------------
   15. Responsive — off-canvas sidebar under 992px
   -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }

  .main-content {
    margin-left: 0;
    padding: 4.5rem 1.15rem 2.5rem;
  }

  #sidebarToggle {
    display: inline-flex;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 0 0 40px rgba(2, 6, 23, 0.5);
  }

  body.sidebar-open .sidebar-overlay {
    opacity: 1;
    visibility: visible;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .page-header h1 {
    font-size: 1.3rem;
  }

  .card-panel {
    padding: 1.15rem;
  }
}

@media (max-width: 575.98px) {
  .stat-cards,
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
  }

  .stat-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 1.1rem;
  }

  .stat-card .stat-value {
    font-size: 1.45rem;
  }

  .flash-container {
    top: auto;
    bottom: 1rem;
    right: 50%;
    transform: translateX(50%);
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* --------------------------------------------------------------------------
   16. Motion preferences
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
