@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Vibrant Clean Modern Palette */
  --bg-app: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F1F5F9;
  --bg-hover: #E2E8F0;

  /* Clean Light Sidebar */
  --bg-sidebar: #FFFFFF;
  --bg-sidebar-hover: #F0FDFA;
  --bg-sidebar-active: #CCFBF1;

  /* Typography */
  --text-primary: #0F172A;
  --text-secondary: #334155;
  --text-muted: #64748B;

  /* Primary Energetic Modern Teal & Cyan Gradient */
  --primary: #0D9488;
  --primary-hover: #0F766E;
  --primary-active: #115E59;
  --primary-light: #CCFBF1;
  --primary-subtle: #F0FDFA;
  --primary-gradient: linear-gradient(135deg, #0D9488 0%, #14B8A6 100%);
  --primary-gradient-hover: linear-gradient(135deg, #0F766E 0%, #0D9488 100%);

  /* Vivid Accents */
  --accent-blue: #4F46E5;
  --accent-blue-hover: #4338CA;
  --accent-blue-light: #EEF2FF;
  --accent-blue-border: #C7D2FE;

  --accent-amber: #D97706;
  --accent-amber-light: #FFFBEB;
  --accent-amber-border: #FDE68A;

  --accent-red: #E11D48;
  --accent-red-hover: #BE123C;
  --accent-red-light: #FFF1F2;
  --accent-red-border: #FECDD3;

  --accent-green: #059669;
  --accent-green-hover: #047857;
  --accent-green-light: #ECFDF5;
  --accent-green-border: #A7F3D0;

  --accent-purple: #7C3AED;
  --accent-purple-light: #F5F3FF;
  --accent-purple-border: #DDD6FE;

  /* Borders & Radii */
  --border-color: #E2E8F0;
  --border-strong: #CBD5E1;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* Soft Elevation Shadows with subtle vibrant ambient reflection */
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 4px 14px -1px rgba(15, 23, 42, 0.07), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 16px 36px -4px rgba(15, 23, 42, 0.1), 0 6px 12px -2px rgba(15, 23, 42, 0.04);
  --shadow-hover: 0 10px 25px -3px rgba(15, 23, 42, 0.09), 0 4px 10px -2px rgba(15, 23, 42, 0.05);
  --shadow-primary: 0 6px 18px rgba(13, 148, 136, 0.28);
  --shadow-primary-hover: 0 8px 26px rgba(13, 148, 136, 0.4);

  --sidebar-width: 265px;
  --header-height: 64px;
  --font-sans: 'IBM Plex Sans Arabic', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, monospace;
}

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

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================================
   PAGE & ELEMENT ANIMATIONS (LIVELY PHYSICS)
   ============================================================================ */
@keyframes pageFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes modalPop {
  0% {
    opacity: 0;
    transform: scale(0.94) translateY(14px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes toastSpring {
  0% {
    opacity: 0;
    transform: translateY(22px) scale(0.92);
  }
  60% {
    transform: translateY(-4px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes logoGlow {
  0%, 100% {
    box-shadow: 0 4px 14px rgba(13, 148, 136, 0.3);
  }
  50% {
    box-shadow: 0 6px 22px rgba(20, 184, 166, 0.55);
  }
}

@keyframes pulseSubtle {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.06);
    opacity: 0.9;
  }
}

/* ============================================================================
   LOGIN SCREEN
   ============================================================================ */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 10% 20%, #F0FDFA 0%, #F8FAFC 55%, #EEF2FF 100%);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 38px 34px;
  animation: modalPop 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-card:hover {
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.12);
  transform: translateY(-2px);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}

.auth-brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--primary-gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
  box-shadow: var(--shadow-primary);
  animation: logoGlow 4s infinite ease-in-out;
}

.auth-brand-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.auth-brand-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ============================================================================
   MAIN APP LAYOUT (SIDEBAR + CONTENT)
   ============================================================================ */
.app-shell {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--bg-app);
}

.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-app);
  color: var(--text-primary);
  border-inline-end: 1px solid var(--border-color);
  padding: 10px 10px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width 0.26s cubic-bezier(0.16, 1, 0.3, 1), padding 0.26s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease, transform 0.26s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
}

.app-shell.sidebar-collapsed .sidebar {
  width: 0;
  padding-inline: 0;
  border-inline-end-width: 0;
  opacity: 0;
  pointer-events: none;
}

.sidebar-restore-btn {
  display: none !important;
  position: fixed;
  top: 20px;
  inset-inline-start: 20px;
  z-index: 150;
  box-shadow: var(--shadow-md);
}

.app-shell.sidebar-collapsed .sidebar-restore-btn {
  display: inline-flex !important;
}

.app-shell.sidebar-collapsed .toolbar {
  padding-inline-start: 92px;
}

.sidebar-inner {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: calc(100vh - 20px);
  height: fit-content;
  transition: box-shadow 0.25s ease;
}

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

.sidebar-header {
  height: 48px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(180deg, #FFFFFF 0%, #FAFCFD 100%);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.sidebar-logo-badge {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--primary-gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow-primary);
  animation: logoGlow 4s infinite ease-in-out;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sidebar-logo:hover .sidebar-logo-badge {
  transform: rotate(-10deg) scale(1.12);
}

.sidebar-nav {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  min-height: 0;
  flex: 1 1 auto;
}

.nav-group-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 6px 10px 2px;
  font-weight: 700;
  flex-shrink: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6.5px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  width: 100%;
  text-align: inherit;
  flex-shrink: 0;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-item:hover {
  background: linear-gradient(90deg, #F0FDFA 0%, #FFFFFF 100%);
  color: var(--primary);
  transform: translateX(-4px);
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.08);
}

[dir="ltr"] .nav-item:hover {
  transform: translateX(4px);
}

.nav-item:active {
  transform: scale(0.97) !important;
}

.nav-item-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-item:hover .nav-item-icon {
  transform: scale(1.22) rotate(-8deg);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.12) 0%, rgba(20, 184, 166, 0.05) 100%);
  color: var(--primary);
  font-weight: 700;
  border-color: rgba(13, 148, 136, 0.22);
  border-inline-start: 3.5px solid var(--primary);
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.08);
  transform: none;
}

.nav-item.active .nav-item-icon {
  transform: scale(1.12);
}

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  background-color: var(--bg-app);
}

.mobile-top-bar {
  display: none;
  padding: 10px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  align-items: center;
  justify-content: space-between;
}

.mobile-menu-btn {
  display: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  transition: all 0.2s;
}

.mobile-menu-btn:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.user-pill:hover {
  background: #E2E8F0;
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13.5px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

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

.page-content {
  flex: 1;
  padding: 24px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  animation: pageFadeIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.page-content-anim {
  animation: pageFadeIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* ============================================================================
   CARDS, GRIDS & METRICS
   ============================================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  inset-inline-end: 0;
  height: 3px;
  background: transparent;
  transition: background 0.25s ease;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: #CBD5E1;
}

.stat-card:hover::before {
  background: var(--primary-gradient);
}

.stat-card-label {
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-card-value {
  font-size: 23px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.4px;
}

.stat-card-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.card:hover {
  box-shadow: var(--shadow-hover);
  border-color: #CBD5E1;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: linear-gradient(180deg, #FFFFFF 0%, #FAFCFD 100%);
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-body {
  padding: 20px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* ============================================================================
   BUTTONS, INPUTS, FILTERS & TABS (TACTILE INTERACTIONS)
   ============================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  user-select: none;
  position: relative;
  overflow: hidden;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(1px) scale(0.97) !important;
  transition-duration: 0.08s;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #fff;
  border: none;
  box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
  background: var(--primary-gradient-hover);
  box-shadow: var(--shadow-primary-hover);
  filter: brightness(1.04);
}

.btn-secondary {
  background: #FFFFFF;
  color: var(--text-secondary);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: #F8FAFC;
  color: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.14);
}

.btn-danger {
  background: var(--accent-red-light);
  color: var(--accent-red);
  border-color: var(--accent-red-border);
}

.btn-danger:hover {
  background: var(--accent-red);
  color: #FFFFFF;
  border-color: var(--accent-red);
  box-shadow: 0 6px 18px rgba(225, 29, 72, 0.32);
}

.btn-success {
  background: linear-gradient(135deg, #059669 0%, #10B981 100%);
  color: #fff;
  border: none;
  box-shadow: 0 6px 18px rgba(5, 150, 105, 0.26);
}

.btn-success:hover {
  background: linear-gradient(135deg, #047857 0%, #059669 100%);
  box-shadow: 0 8px 24px rgba(5, 150, 105, 0.38);
  filter: brightness(1.04);
}

.btn-expense {
  background: #FFF1F2;
  color: #BE123C;
  border-color: #FDA4AF;
  box-shadow: var(--shadow-sm);
}

.btn-expense:hover {
  background: #E11D48;
  color: #FFFFFF;
  border-color: #E11D48;
  box-shadow: 0 6px 18px rgba(225, 29, 72, 0.28);
}

.btn-copied {
  background: #ECFDF5 !important;
  color: #059669 !important;
  border-color: #A7F3D0 !important;
  transform: scale(1.05) !important;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
  border-radius: 6px;
}

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

.filters-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

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

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

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-primary);
  background: var(--bg-surface);
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.form-control:hover {
  border-color: #94A3B8;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3.5px rgba(13, 148, 136, 0.16), 0 2px 8px rgba(13, 148, 136, 0.08);
  background: #FFFFFF;
  transform: translateY(-1px);
}

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

.code-textarea {
  font-family: var(--font-mono);
  direction: ltr;
  text-align: left;
  font-size: 13px;
  background: #0F172A;
  color: #E2E8F0;
  min-height: 160px;
  border-radius: var(--radius-sm);
  padding: 12px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.3);
}

.tabs-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 1px;
}

.tab-btn {
  padding: 9px 18px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2.5px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab-btn:hover {
  color: var(--primary);
  background: rgba(13, 148, 136, 0.05);
  transform: translateY(-1.5px);
}

.tab-btn:active {
  transform: scale(0.97);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(13, 148, 136, 0.07);
  transform: none;
}

/* ============================================================================
   TABLES & BADGES
   ============================================================================ */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  text-align: inherit;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.data-table th {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
}

.data-table tbody tr {
  transition: all 0.18s ease;
}

.data-table tbody tr:hover {
  background-color: #F8FAFC;
  transform: scale(1.002);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.03);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: all 0.18s ease;
}

.badge-teal {
  background: var(--primary-light);
  color: var(--primary-hover);
  border-color: #99F6E4;
}

.badge-green {
  background: var(--accent-green-light);
  color: var(--accent-green);
  border-color: var(--accent-green-border);
}

.badge-amber {
  background: var(--accent-amber-light);
  color: var(--accent-amber);
  border-color: var(--accent-amber-border);
}

.badge-red {
  background: var(--accent-red-light);
  color: var(--accent-red);
  border-color: var(--accent-red-border);
}

.badge-blue {
  background: var(--accent-blue-light);
  color: var(--accent-blue);
  border-color: var(--accent-blue-border);
}

.badge-purple {
  background: var(--accent-purple-light);
  color: var(--accent-purple);
  border-color: var(--accent-purple-border);
}

.badge-slate {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.badge-pulse {
  animation: pulseSubtle 2.2s infinite ease-in-out;
}

/* ============================================================================
   KANBAN BOARD & PROGRESS BARS
   ============================================================================ */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(240px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.kanban-col {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 360px;
}

.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 13.5px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.kanban-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 13px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: grab;
}

.kanban-card:hover {
  transform: translateY(-3px) scale(1.01);
  box-shadow: var(--shadow-hover);
  border-color: #94A3B8;
}

.kanban-card:active {
  cursor: grabbing;
  transform: scale(0.99);
}

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--bg-subtle);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: 999px;
  transition: width 0.35s ease;
}

/* ============================================================================
   CODE BLOCKS & CALENDAR
   ============================================================================ */
.code-block {
  background: #0F172A;
  color: #F8FAFC;
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 14px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  direction: ltr;
  text-align: left;
  line-height: 1.55;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}

.prompt-block {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  padding: 14px;
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  font-size: 13.5px;
  line-height: 1.65;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 8px;
}

.calendar-day-cell {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  min-height: 105px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.2s ease;
}

.calendar-day-cell:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-sm);
}

.calendar-day-cell.today {
  border-color: var(--primary);
  background: var(--primary-subtle);
}

.calendar-day-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.calendar-event-pill {
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 4px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  transition: transform 0.15s ease;
}

.calendar-event-pill:hover {
  transform: scale(1.02);
}

/* ============================================================================
   MODALS, EMPTY STATES & TOASTS (SPRING PHYSICS)
   ============================================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

.modal-box {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalPop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid var(--border-color);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #FFFFFF 0%, #FAFCFD 100%);
}

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

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

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

.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.toast-container {
  position: fixed;
  bottom: 24px;
  inset-inline-end: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: #0F172A;
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 10px 25px -4px rgba(15, 23, 42, 0.25);
  border-inline-start: 4px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastSpring 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: all 0.25s ease;
}

.toast.toast-exit {
  opacity: 0;
  transform: translateY(12px) scale(0.9);
}

.toast.error {
  border-inline-start-color: var(--accent-red);
  background: #1E1B2E;
}

.toast-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.toast.error .toast-icon {
  background: var(--accent-red);
}

/* ============================================================================
   ENHANCED UX COMPONENTS (SEARCH, STICKY TABLES, DROPDOWNS, KANBAN DRAG)
   ============================================================================ */
.search-box-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.search-box-wrap .form-control {
  padding-inline-end: 30px;
}

.search-clear-btn {
  position: absolute;
  inset-inline-end: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 11px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  padding: 0;
  line-height: 1;
}

.search-clear-btn.visible {
  display: inline-flex;
}

.search-clear-btn:hover {
  background: var(--accent-red-light);
  color: var(--accent-red);
  border-color: var(--accent-red-border);
}

.docs-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
}

.data-table.sticky-first th:first-child,
.data-table.sticky-first td:first-child {
  position: sticky;
  inset-inline-start: 0;
  z-index: 2;
  background: var(--bg-surface);
  box-shadow: -2px 0 6px rgba(15, 23, 42, 0.04);
}

[dir="ltr"] .data-table.sticky-first th:first-child,
[dir="ltr"] .data-table.sticky-first td:first-child {
  box-shadow: 2px 0 6px rgba(15, 23, 42, 0.04);
}

.data-table.sticky-first th:first-child {
  background: var(--bg-subtle);
  z-index: 3;
}

.data-table.sticky-first tbody tr:hover td:first-child {
  background: #F8FAFC;
}

.kanban-col.drag-over {
  background: var(--primary-subtle);
  border-color: var(--primary);
  box-shadow: inset 0 0 0 2px rgba(13, 148, 136, 0.25);
}

.kanban-card.dragging {
  opacity: 0.45;
  transform: scale(0.96);
}

.row-actions-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.row-actions-dropdown {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 4px);
  min-width: 160px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 5px;
  z-index: 80;
  display: none;
  flex-direction: column;
  gap: 2px;
}

.row-actions-dropdown.open {
  display: flex;
  animation: fadeIn 0.15s ease-out;
}

.row-action-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  text-align: start;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.row-action-item:hover {
  background: var(--bg-subtle);
  color: var(--primary);
}

.row-action-item.danger {
  color: var(--accent-red);
}

.row-action-item.danger:hover {
  background: var(--accent-red-light);
}

.empty-state-icon {
  font-size: 34px;
  margin-bottom: 10px;
  opacity: 0.85;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(2px);
  z-index: 95;
  animation: fadeIn 0.2s ease;
}

/* ============================================================================
   RESPONSIVE MEDIA QUERIES (TABLET & MOBILE)
   ============================================================================ */
@media (max-width: 992px) {
  .grid-2, .grid-3, .docs-layout {
    grid-template-columns: 1fr !important;
  }

  .mobile-top-bar {
    display: flex !important;
  }

  .mobile-menu-btn {
    display: inline-flex !important;
  }

  .sidebar-backdrop.open {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    transform: translateX(100%);
    box-shadow: var(--shadow-lg);
  }

  [dir="ltr"] .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0) !important;
  }

  .page-content {
    padding: 16px;
  }
}

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

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .filters-bar {
    width: 100%;
  }

  .filters-bar .form-control,
  .filters-bar .search-box-wrap {
    width: 100% !important;
    flex: 1 1 100%;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .modal-body {
    padding: 14px;
  }

  .data-table th,
  .data-table td {
    padding: 9px 10px;
  }
}
