/* ─── Design System 2026 ─────────────────────────────────────────────────── */

:root {
  /* Motion */
  --motion-fast: 150ms;
  --motion-base: 220ms;
  --motion-slow: 350ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-emphasized: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Light theme */
  --bg-body: #F1F5F9;
  --bg-surface: #FFFFFF;
  --bg-surface-elevated: #F8FAFC;
  --bg-sidebar: #1E293B;
  --bg-sidebar-hover: rgba(255,255,255,0.08);
  --bg-sidebar-active: rgba(99,102,241,0.22);
  --bg-input: #F1F5F9;
  --bg-hover: #E2E8F0;
  --bg-selected: #E0E7FF;
  --bg-glass: rgba(255,255,255,0.85);

  --text-primary: #0F172A;
  --text-secondary: #334155;
  --text-tertiary: #64748B;
  --text-inverse: #F8FAFC;
  --text-sidebar: #F1F5F9;
  --text-sidebar-muted: #94A3B8;
  --text-sidebar-active: #FFFFFF;
  --icon-sidebar-active: #FFFFFF;

  --border-subtle: rgba(148,163,184,0.30);
  --border-default: rgba(100,116,139,0.40);
  --border-focus: #4F46E5;

  --accent-primary: #4F46E5;
  --accent-primary-hover: #4338CA;
  --accent-gradient: linear-gradient(135deg, #4F46E5 0%, #7C3AED 50%, #DB2777 100%);
  --accent-glow: rgba(79,70,229,0.35);

  --shadow-xs: 0 1px 2px rgba(15,23,42,0.06);
  --shadow-sm: 0 1px 3px rgba(15,23,42,0.08), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md: 0 4px 6px -1px rgba(15,23,42,0.08), 0 2px 4px -2px rgba(15,23,42,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(15,23,42,0.10), 0 4px 6px -4px rgba(15,23,42,0.06);
  --shadow-xl: 0 20px 25px -5px rgba(15,23,42,0.12), 0 8px 10px -6px rgba(15,23,42,0.08);
  --shadow-glow: 0 0 20px rgba(79,70,229,0.18);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
}

/* System dark mode (only when no manual override) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-body: #020617;
    --bg-surface: #0F172A;
    --bg-surface-elevated: #1E293B;
    --bg-sidebar: #020617;
    --bg-sidebar-hover: rgba(255,255,255,0.04);
    --bg-sidebar-active: rgba(99,102,241,0.22);
    --bg-input: #1E293B;
    --bg-hover: rgba(255,255,255,0.03);
    --bg-selected: rgba(99,102,241,0.12);
    --bg-glass: rgba(15,23,42,0.64);

    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-tertiary: #64748B;
    --text-inverse: #0F172A;
    --text-sidebar: #CBD5E1;
    --text-sidebar-muted: #475569;
    --text-sidebar-active: #F8FAFC;
    --icon-sidebar-active: #F8FAFC;

    --border-subtle: rgba(255,255,255,0.06);
    --border-default: rgba(255,255,255,0.1);
    --border-focus: #818CF8;

    --accent-primary: #818CF8;
    --accent-primary-hover: #6366F1;
    --accent-gradient: linear-gradient(135deg, #818CF8 0%, #A78BFA 50%, #F472B6 100%);
    --accent-glow: rgba(129,140,248,0.4);

    --shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.25), 0 1px 2px rgba(0,0,0,0.15);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.35), 0 4px 6px -4px rgba(0,0,0,0.2);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.4), 0 8px 10px -6px rgba(0,0,0,0.25);
    --shadow-glow: 0 0 30px rgba(129,140,248,0.2);
  }
}

/* Manual dark mode override */
:root[data-theme="dark"] {
  --bg-body: #020617;
  --bg-surface: #0F172A;
  --bg-surface-elevated: #1E293B;
  --bg-sidebar: #0B1120;
  --bg-sidebar-hover: rgba(255,255,255,0.06);
  --bg-sidebar-active: rgba(99,102,241,0.18);
  --bg-input: #1E293B;
  --bg-hover: rgba(255,255,255,0.03);
  --bg-selected: rgba(99,102,241,0.12);
  --bg-glass: rgba(15,23,42,0.64);

  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-tertiary: #64748B;
  --text-inverse: #0F172A;
  --text-sidebar: #CBD5E1;
  --text-sidebar-muted: #64748B;
  --text-sidebar-active: #F8FAFC;
  --icon-sidebar-active: #F8FAFC;

  --border-subtle: rgba(255,255,255,0.06);
  --border-default: rgba(255,255,255,0.1);
  --border-focus: #818CF8;

  --accent-primary: #818CF8;
  --accent-primary-hover: #6366F1;
  --accent-gradient: linear-gradient(135deg, #818CF8 0%, #A78BFA 50%, #F472B6 100%);
  --accent-glow: rgba(129,140,248,0.4);

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.25), 0 1px 2px rgba(0,0,0,0.15);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.35), 0 4px 6px -4px rgba(0,0,0,0.2);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.4), 0 8px 10px -6px rgba(0,0,0,0.25);
  --shadow-glow: 0 0 30px rgba(129,140,248,0.2);
}

/* ─── Base ───────────────────────────────────────────────────────────────── */

body {
  background: var(--bg-body);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Role visibility remains enforced even if navigation classes are changed later. */
:root[data-user-role="admin"] #sidebar .sidebar-nav [data-page]:not([data-page="admin"]):not([data-page="analytics"]),
:root[data-user-role="admin"] #sidebar .sidebar-stats,
:root[data-user-role="admin"] #sidebar .sidebar-utility-divider {
  display: none !important;
}

:root[data-user-role="admin"] #sidebar .sidebar-nav [data-page="admin"],
:root[data-user-role="admin"] #sidebar .sidebar-nav [data-page="analytics"] {
  display: flex !important;
}

:root[data-user-role="user"] #sidebar .sidebar-nav [data-page="admin"],
:root[data-user-role="user"] #sidebar .sidebar-nav [data-page="analytics"] {
  display: none !important;
}

:root[data-user-role="admin"] #user-menu [data-page="profile"] {
  display: flex !important;
  cursor: default;
}

.auth-screen {
  background: var(--bg-body);
}
.auth-container {
  min-height: 100vh;
}
.auth-brand {
  background:
    radial-gradient(circle at 20% 30%, rgba(99,102,241,0.55), transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(139,92,246,0.45), transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(236,72,153,0.25), transparent 55%),
    linear-gradient(145deg, #0F172A 0%, #1E1B4B 60%, #312E81 100%);
  overflow: hidden;
}
.auth-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  animation: authBlobFloat 10s ease-in-out infinite;
}
.auth-blob-1 {
  width: 22rem;
  height: 22rem;
  background: rgba(99,102,241,0.55);
  top: -6rem;
  right: -6rem;
  animation-delay: 0s;
}
.auth-blob-2 {
  width: 18rem;
  height: 18rem;
  background: rgba(139,92,246,0.5);
  bottom: 10%;
  left: -5rem;
  animation-delay: -3.5s;
}
.auth-blob-3 {
  width: 14rem;
  height: 14rem;
  background: rgba(236,72,153,0.45);
  bottom: -4rem;
  right: 20%;
  animation-delay: -7s;
}
@keyframes authBlobFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-18px) scale(1.04); }
}
.auth-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 1.75rem;
  width: 100%;
}
#auth-heading {
  transition: opacity var(--motion-fast) var(--ease-standard);
}

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ─── Glass morphism utilities ───────────────────────────────────────────── */

.glass {
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border-subtle);
}

.glass-strong {
  background: var(--bg-glass);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid var(--border-default);
}

/* ─── Priority indicators ────────────────────────────────────────────────── */

.priority-critical { border-left: 3px solid #EF4444; animation: pulse-red 2s ease-in-out infinite; }
.priority-high     { border-left: 3px solid #F97316; }
.priority-medium   { border-left: 3px solid #6366F1; }
.priority-low      { border-left: 3px solid #94A3B8; }

/* ─── AI loading ─────────────────────────────────────────────────────────── */

.ai-loading { animation: glow 1.4s ease-in-out infinite; pointer-events: none; }

/* ─── SortableJS ─────────────────────────────────────────────────────────── */

.sortable-ghost  { opacity: 0.3; transform: scale(0.98); }
.sortable-chosen { cursor: grabbing !important; }
.kanban-col      { min-height: 180px; }

/* ─── Quick Add ──────────────────────────────────────────────────────────── */

.quick-add-wrap {
  transition: max-width var(--motion-base) var(--ease-standard);
}
.quick-add-wrap:focus-within,
.quick-add-wrap.has-content {
  max-width: 44rem;
}
.quick-add-input {
  height: 2.75rem;
  min-height: 2.75rem;
  max-height: 8.5rem;
  transition:
    height var(--motion-base) var(--ease-standard),
    min-height var(--motion-base) var(--ease-standard),
    background-color var(--motion-fast) var(--ease-standard),
    box-shadow var(--motion-fast) var(--ease-standard);
  background: var(--bg-input);
  border-color: var(--border-default);
}
.quick-add-input:focus {
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow-sm);
  border-color: var(--accent-primary);
}
.quick-add-wrap:focus-within .quick-add-input {
  min-height: 5.75rem;
}

/* ─── Subtask toggle ─────────────────────────────────────────────────────── */

.subtask-toggle {
  cursor: pointer;
  transition:
    border-color var(--motion-fast) var(--ease-standard),
    background-color var(--motion-fast) var(--ease-standard),
    box-shadow var(--motion-fast) var(--ease-standard),
    transform var(--motion-fast) var(--ease-bounce);
}
.subtask-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.subtask-toggle:active {
  transform: scale(0.92);
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */

.app-sidebar {
  background: var(--bg-sidebar);
  transition: width var(--motion-base) var(--ease-standard);
  border-right: 1px solid var(--border-subtle);
}
.app-sidebar.sidebar-preload,
.app-sidebar.sidebar-preload .sidebar-label,
.app-sidebar.sidebar-preload .nav-link,
.app-sidebar.sidebar-preload .stat-row,
.app-sidebar.sidebar-preload #sidebar-toggle {
  transition: none !important;
}
.app-sidebar .sidebar-label {
  opacity: 1;
  white-space: nowrap;
  transition: opacity var(--motion-fast) var(--ease-standard);
}
.app-sidebar .nav-icon {
  flex-shrink: 0;
  transition: color var(--motion-fast) var(--ease-standard), transform var(--motion-fast) var(--ease-bounce);
}
.app-sidebar .nav-link {
  color: var(--text-sidebar-muted);
}
.app-sidebar .nav-link .nav-icon {
  color: var(--text-sidebar-muted);
}
.app-sidebar .nav-link:hover {
  color: var(--text-sidebar);
}
.app-sidebar .nav-link:hover .nav-icon {
  color: var(--text-sidebar);
}
.nav-link {
  position: relative;
  transition: all var(--motion-fast) var(--ease-standard);
}
.nav-link::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--bg-sidebar-hover);
  opacity: 0;
  transition: opacity var(--motion-fast) var(--ease-standard);
}
.nav-link:hover::before {
  opacity: 1;
}
.nav-link:hover .nav-icon {
  transform: scale(1.1);
}
.nav-active {
  background: var(--bg-sidebar-active) !important;
  color: var(--text-sidebar-active) !important;
  box-shadow: inset 0 0 0 1px rgba(99,102,241,0.15), 0 0 12px var(--accent-glow);
}
.nav-active .nav-icon {
  color: var(--icon-sidebar-active);
}
.app-sidebar.is-collapsed {
  width: 4.5rem !important;
}
.app-sidebar.is-collapsed .sidebar-brand {
  padding-left: 1rem;
  padding-right: 1rem;
  justify-content: center;
}
.app-sidebar.is-collapsed .sidebar-logo {
  display: none;
}
.app-sidebar.is-collapsed .sidebar-label {
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  width: 1px;
}
@media (min-width: 1024px) {
  .app-sidebar.is-collapsed #sidebar-toggle {
    margin-left: 0;
  }
}
.app-sidebar.is-collapsed .sidebar-nav {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}
.app-sidebar.is-collapsed .nav-link {
  justify-content: center;
  gap: 0;
  padding-left: 0;
  padding-right: 0;
}
.app-sidebar.is-collapsed .sidebar-stats {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}
.app-sidebar.is-collapsed .stat-row {
  justify-content: center;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0;
}
.app-sidebar.is-collapsed .stat-icon {
  display: block;
}

/* Sidebar theme toggle & user profile collapsed states */
.app-sidebar.is-collapsed .sidebar-theme {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}
.app-sidebar.is-collapsed .sidebar-theme button {
  justify-content: center;
  gap: 0;
  padding-left: 0;
  padding-right: 0;
}
.app-sidebar.is-collapsed .sidebar-user {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}
.app-sidebar.is-collapsed .sidebar-user [data-page="profile"] {
  justify-content: center;
  gap: 0;
  padding-left: 0;
  padding-right: 0;
}
.app-sidebar.is-collapsed .sidebar-user .user-avatar {
  margin: 0;
}
.app-sidebar.is-collapsed .sidebar-user #logout-btn {
  display: flex;
  justify-content: center;
  gap: 0;
  padding-left: 0;
  padding-right: 0;
}

.sidebar-user [data-page="profile"].nav-active {
  background: var(--bg-sidebar-active) !important;
  box-shadow: inset 0 0 0 1px rgba(99,102,241,0.15), 0 0 12px var(--accent-glow);
}

/* ─── View toggle ────────────────────────────────────────────────────────── */

.view-active {
  background: var(--bg-surface);
  color: var(--accent-primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

/* ─── Toast ──────────────────────────────────────────────────────────────── */

.toast-in  { animation: slideIn var(--motion-slow) var(--ease-emphasized) forwards; }
.toast-out { animation: slideOut var(--motion-slow) var(--ease-emphasized) forwards; }

/* ─── Modal ──────────────────────────────────────────────────────────────── */

.modal-enter { animation: fadeIn var(--motion-base) var(--ease-emphasized) forwards; }
.modal-backdrop {
  backdrop-filter: blur(8px);
  background: rgba(2,6,23,0.45);
}
.page-panel-enter { animation: pageEnter var(--motion-base) var(--ease-emphasized) both; }

/* ─── Priority / Status pills ────────────────────────────────────────────── */

.pill-critical  { background: rgba(239,68,68,0.10); color: #DC2626; border: 1px solid rgba(239,68,68,0.15); }
.pill-high      { background: rgba(249,115,22,0.10); color: #EA580C; border: 1px solid rgba(249,115,22,0.15); }
.pill-medium    { background: rgba(99,102,241,0.10); color: #4F46E5; border: 1px solid rgba(99,102,241,0.15); }
.pill-low       { background: rgba(148,163,184,0.12); color: #475569; border: 1px solid rgba(148,163,184,0.15); }
.pill-todo      { background: rgba(148,163,184,0.10); color: #475569; border: 1px solid rgba(148,163,184,0.12); }
.pill-inprogress{ background: rgba(99,102,241,0.10); color: #4F46E5; border: 1px solid rgba(99,102,241,0.12); }
.pill-done      { background: rgba(16,185,129,0.10); color: #059669; border: 1px solid rgba(16,185,129,0.12); }

:root[data-theme="dark"] .pill-critical  { background: rgba(239,68,68,0.15); color: #F87171; border-color: rgba(239,68,68,0.2); }
:root[data-theme="dark"] .pill-high      { background: rgba(249,115,22,0.15); color: #FB923C; border-color: rgba(249,115,22,0.2); }
:root[data-theme="dark"] .pill-medium    { background: rgba(99,102,241,0.15); color: #A5B4FC; border-color: rgba(99,102,241,0.2); }
:root[data-theme="dark"] .pill-low       { background: rgba(148,163,184,0.12); color: #94A3B8; border-color: rgba(148,163,184,0.15); }
:root[data-theme="dark"] .pill-todo      { background: rgba(148,163,184,0.08); color: #94A3B8; border-color: rgba(148,163,184,0.1); }
:root[data-theme="dark"] .pill-inprogress{ background: rgba(99,102,241,0.12); color: #A5B4FC; border-color: rgba(99,102,241,0.15); }
:root[data-theme="dark"] .pill-done      { background: rgba(16,185,129,0.12); color: #34D399; border-color: rgba(16,185,129,0.15); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pill-critical  { background: rgba(239,68,68,0.15); color: #F87171; border-color: rgba(239,68,68,0.2); }
  :root:not([data-theme="light"]) .pill-high      { background: rgba(249,115,22,0.15); color: #FB923C; border-color: rgba(249,115,22,0.2); }
  :root:not([data-theme="light"]) .pill-medium    { background: rgba(99,102,241,0.15); color: #A5B4FC; border-color: rgba(99,102,241,0.2); }
  :root:not([data-theme="light"]) .pill-low       { background: rgba(148,163,184,0.12); color: #94A3B8; border-color: rgba(148,163,184,0.15); }
  :root:not([data-theme="light"]) .pill-todo      { background: rgba(148,163,184,0.08); color: #94A3B8; border-color: rgba(148,163,184,0.1); }
  :root:not([data-theme="light"]) .pill-inprogress{ background: rgba(99,102,241,0.12); color: #A5B4FC; border-color: rgba(99,102,241,0.15); }
  :root:not([data-theme="light"]) .pill-done      { background: rgba(16,185,129,0.12); color: #34D399; border-color: rgba(16,185,129,0.15); }
}

/* ─── AI Button ──────────────────────────────────────────────────────────── */

.btn-ai {
  background: var(--accent-gradient);
  position: relative;
  overflow: hidden;
  transition: all var(--motion-fast) var(--ease-standard);
}
.btn-ai::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 60%);
  opacity: 0;
  transition: opacity var(--motion-fast) var(--ease-standard);
}
.btn-ai:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(99,102,241,0.35), 0 0 0 1px rgba(255,255,255,0.1) inset;
}
.btn-ai:hover::before {
  opacity: 1;
}
.btn-ai:active {
  transform: translateY(0);
}

/* ─── Modern Card Styles ─────────────────────────────────────────────────── */

.card-modern {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: all var(--motion-base) var(--ease-standard);
}
.card-modern:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-default);
  transform: translateY(-1px);
}
.card-elevated {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* ─── Table modernization ────────────────────────────────────────────────── */

.table-modern {
  border-collapse: separate;
  border-spacing: 0;
}
.table-modern th {
  background: var(--bg-body);
  color: var(--text-tertiary);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}
.table-modern td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--motion-fast) var(--ease-standard);
}
.table-modern tbody tr:hover td {
  background: var(--bg-hover);
}

/* ─── Kanban column modernization ────────────────────────────────────────── */

.kanban-column {
  background: var(--bg-body);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* ─── Task row modernization ─────────────────────────────────────────────── */

.task-row-modern {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  transition: all var(--motion-base) var(--ease-standard);
  margin-bottom: 0.5rem;
}
.task-row-modern:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-default);
  transform: translateY(-1px);
}

/* ─── Progress bar ───────────────────────────────────────────────────────── */

.progress-bar-modern {
  height: 6px;
  background: var(--bg-input);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar-modern > div {
  height: 100%;
  border-radius: 99px;
  transition: width var(--motion-slow) var(--ease-emphasized);
}

/* ─── Input modernization ────────────────────────────────────────────────── */

.input-modern {
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: all var(--motion-fast) var(--ease-standard);
}
.input-modern:focus {
  outline: none;
  background: var(--bg-surface);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.input-modern::placeholder {
  color: var(--text-tertiary);
}

/* ─── Select modernization ───────────────────────────────────────────────── */

.select-modern {
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: 99px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--motion-fast) var(--ease-standard);
}
.select-modern:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ─── Button modernization ───────────────────────────────────────────────── */

.btn-modern {
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: all var(--motion-fast) var(--ease-standard);
}
.btn-modern:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-modern:active {
  transform: translateY(0);
}

/* ─── Guide ──────────────────────────────────────────────────────────────── */

.guide-progress-bar {
  transition: width var(--motion-base) var(--ease-standard);
}
.guide-shell-note {
  line-height: 1.55;
  background: linear-gradient(135deg, rgba(99,102,241,0.08), rgba(139,92,246,0.05));
  border: 1px solid rgba(99,102,241,0.12);
}
.guide-step {
  overflow: hidden;
  transition: all var(--motion-base) var(--ease-standard);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}
.guide-step:hover {
  border-color: var(--border-default);
}
.guide-step.is-open {
  border-color: rgba(99,102,241,0.25);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(99,102,241,0.06);
}
.guide-step-indicator {
  background: var(--bg-input);
  color: var(--text-secondary);
  transition: all var(--motion-base) var(--ease-standard);
}
.guide-step.is-open .guide-step-indicator {
  background: var(--bg-selected);
  color: var(--accent-primary);
  transform: scale(1.05);
  box-shadow: 0 0 0 1px var(--accent-glow);
}
.guide-step.is-complete .guide-step-indicator {
  background: rgba(16,185,129,0.12);
  color: #059669;
}
.guide-step-chevron {
  transition: transform var(--motion-base) var(--ease-standard), color var(--motion-base) var(--ease-standard);
}
.guide-step.is-open .guide-step-chevron {
  transform: rotate(180deg);
  color: var(--accent-primary);
}
.guide-preview-frame {
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}
.guide-preview-bar {
  backdrop-filter: blur(8px);
  background: var(--bg-glass);
  border-bottom: 1px solid var(--border-subtle);
}
.guide-step-panel {
  line-height: 1.55;
  background: var(--bg-body);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}
.guide-step-list {
  margin: 0;
  padding-left: 1rem;
}
.guide-dot {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 9999px;
}
.guide-preview-target {
  position: relative;
  z-index: 0;
  animation: guide-pulse 2s ease-in-out infinite;
  box-shadow: 0 0 0 0 var(--accent-glow);
}
@media (max-width: 1023px) {
  .guide-force-actions {
    opacity: 1 !important;
  }
}
.guide-complete-btn:disabled {
  background: #10B981;
  cursor: default;
}

/* ─── Nav link help accent ───────────────────────────────────────────────── */

.nav-link-help {
  background: transparent;
}

/* ─── Header / Top bar ───────────────────────────────────────────────────── */

.top-bar-modern {
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-subtle);
}

/* ─── Empty states ───────────────────────────────────────────────────────── */

.empty-state-modern {
  opacity: 0.6;
  transition: opacity var(--motion-base) var(--ease-standard);
}
.empty-state-modern:hover {
  opacity: 0.8;
}

/* ─── Animations ─────────────────────────────────────────────────────────── */

@keyframes pulse-red {
  0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
  50%      { box-shadow: 0 0 0 4px rgba(239,68,68,0.18); }
}
@keyframes glow {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.5; }
}
@keyframes slideIn {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes slideOut {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(110%); opacity: 0; }
}
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes guide-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 var(--accent-glow), 0 0 0 2px rgba(99, 102, 241, 0.2);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(99, 102, 241, 0), 0 0 0 2px rgba(99, 102, 241, 0.35);
  }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ─── Reduced motion ─────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 920px) {
  header.top-bar-modern { flex-wrap: wrap; }
  .quick-add-wrap { flex-basis: 100%; max-width: none; }
  #new-subtask-wrap { grid-template-columns: 1fr; }
  #subtask-list > div { grid-template-columns: auto 1fr auto; }
  #subtask-list .sub-due { grid-column: 2 / -1; width: 100%; }
  .guide-step-header { align-items: flex-start; }
  .guide-step-header .guide-step-indicator { margin-top: 0.125rem; }
}

/* ─── Mobile / Tablet portrait (≤1023px) ─────────────────────────────────── */

@media (max-width: 1023px) {
  /* Sidebar becomes an overlay drawer */
  #sidebar.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 16rem !important;
    z-index: 60 !important;
    transform: translateX(-100%);
    transition: transform var(--motion-base) var(--ease-standard);
  }
  #sidebar.app-sidebar.is-open {
    transform: translateX(0);
  }
  /* Force mobile drawer to always show labels and logout even if is-collapsed leaks */
  #sidebar.app-sidebar .sidebar-label,
  #sidebar.app-sidebar.is-collapsed .sidebar-label {
    opacity: 1 !important;
    overflow: visible !important;
    pointer-events: auto !important;
    position: static !important;
    width: auto !important;
  }
  #sidebar.app-sidebar.is-collapsed #logout-btn,
  #sidebar.app-sidebar #logout-btn {
    display: flex !important;
  }
  #sidebar.app-sidebar.is-collapsed .sidebar-logo {
    display: block !important;
  }
  #sidebar.app-sidebar.is-collapsed .sidebar-brand {
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
    justify-content: flex-start !important;
  }
  #sidebar.app-sidebar.is-collapsed .nav-link {
    justify-content: flex-start !important;
    gap: 0.75rem !important;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
  /* Sidebar overlay backdrop */
  #sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(4px);
    z-index: 55;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--motion-base) var(--ease-standard);
  }
  #sidebar-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }
  /* Hide desktop sidebar toggle; show mobile hamburger in top bar instead */
  #sidebar-toggle {
    display: none !important;
  }

  /* Top bar: stack and compress */
  header.top-bar-modern {
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
  }
  header.top-bar-modern .quick-add-wrap {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }
  header.top-bar-modern #quick-add-btn {
    order: 4;
    flex: 1 1 auto;
    justify-content: center;
  }
  header.top-bar-modern #view-toggle {
    order: 5;
    flex: 1 1 auto;
    justify-content: center;
  }
  header.top-bar-modern .h-6.w-px {
    display: none;
  }
  /* Mobile page title next to hamburger */
  header.top-bar-modern > .lg\:hidden {
    order: 2;
    flex: 0 1 auto;
    min-width: 0;
  }
  #mobile-sidebar-toggle {
    flex: 0 0 auto;
    width: 2.25rem !important;
    height: 2.25rem !important;
  }
  /* Shorter placeholder on mobile */
  #quick-add-input::placeholder {
    font-size: 0.75rem;
  }
  /* View toggle fills its well on mobile */
  #view-toggle {
    width: 100%;
  }
  #view-toggle .view-btn {
    flex: 1 1 0;
    justify-content: center;
  }

  /* Page panels: reduce padding */
  .page-panel {
    padding: 0.75rem !important;
  }
  /* Hide original page heading on mobile (shown in top bar instead) */
  .page-heading-block {
    display: none !important;
  }
  .page-panel > .flex.items-center.justify-between {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .page-panel > .flex.items-center.justify-between > .flex.items-center.gap-2 {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  /* Task list: card-based layout instead of table */
  #list-view .table-modern thead {
    display: none;
  }
  #list-view .table-modern,
  #list-view .table-modern tbody,
  #list-view .table-modern td {
    display: block;
    width: 100% !important;
  }
  #list-view .table-modern tr.task-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
  }
  #list-view .table-modern tr.task-row {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    position: relative;
  }
  #list-view .table-modern tr.task-row td {
    padding: 0.25rem 0 !important;
    border: none !important;
    background: transparent !important;
  }
  /* Row 1: checkbox/expand + title inline */
  #list-view .table-modern tr.task-row td:first-child,
  #list-view .table-modern tr.task-row td:nth-child(2) {
    width: auto !important;
    padding: 0 !important;
    margin-bottom: 0.5rem;
    order: 1;
  }
  #list-view .table-modern tr.task-row td:first-child {
    padding-right: 0.5rem !important;
    flex: 0 0 auto;
  }
  #list-view .table-modern tr.task-row td:nth-child(2) {
    flex: 1 1 0;
    min-width: 0;
    padding-right: 2.5rem !important;
  }
  /* Full-width line break between title and metadata */
  #list-view .table-modern tr.task-row::before {
    content: '';
    display: block;
    width: 100%;
    height: 0;
    flex-basis: 100%;
    order: 2;
  }
  /* Row 2: priority + status + date in one line */
  #list-view .table-modern tr.task-row td:nth-child(3),
  #list-view .table-modern tr.task-row td:nth-child(4),
  #list-view .table-modern tr.task-row td:nth-child(5) {
    display: inline-block !important;
    width: auto !important;
    vertical-align: middle;
    margin-right: 0.5rem;
    margin-bottom: 0.25rem;
    order: 3;
  }
  /* Row 3: progress bar */
  #list-view .table-modern tr.task-row td:nth-child(6) {
    margin-top: 0.25rem;
    order: 4;
  }
  /* Row 4: action buttons positioned top-right */
  #list-view .table-modern tr.task-row td:nth-child(7) {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: auto !important;
    padding: 0 !important;
    order: 5;
  }
  #list-view .table-modern tr.subtask-row {
    background: var(--bg-hover);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    margin-left: 1.5rem;
    padding: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    position: relative;
  }
  #list-view .table-modern tr.subtask-row td {
    padding: 0.25rem 0 !important;
    border: none !important;
    background: transparent !important;
  }
  #list-view .table-modern tr.subtask-row td:first-child {
    display: none;
  }
  /* Remove desktop connector line indentation on mobile */
  #list-view .table-modern tr.subtask-row td .relative.pl-8 {
    padding-left: 0 !important;
  }
  #list-view .table-modern tr.subtask-row td .relative.pl-8 > .absolute.left-3 {
    display: none;
  }
  /* Subtask: checkbox + title inline */
  #list-view .table-modern tr.subtask-row td:nth-child(2) {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    width: 100% !important;
    margin-bottom: 0.5rem;
    flex: none !important;
    padding-right: 2.5rem !important;
  }
  /* Subtask metadata inline */
  #list-view .table-modern tr.subtask-row td:nth-child(3),
  #list-view .table-modern tr.subtask-row td:nth-child(4),
  #list-view .table-modern tr.subtask-row td:nth-child(5) {
    display: inline-block !important;
    width: auto !important;
    vertical-align: middle;
    margin-right: 0.5rem;
    margin-bottom: 0.25rem;
  }
  /* Subtask action buttons top-right */
  #list-view .table-modern tr.subtask-row td:nth-child(7) {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: auto !important;
    padding: 0 !important;
  }
  /* Ensure task action buttons are always visible on mobile (no hover) */
  #list-view .task-row .edit-btn,
  #list-view .task-row .del-btn,
  #list-view .subtask-row .subtask-edit-btn,
  #list-view .subtask-row .subtask-del-btn {
    opacity: 1 !important;
  }

  /* Archive table: same card treatment */
  #page-archive .table-modern thead {
    display: none;
  }
  #page-archive .table-modern,
  #page-archive .table-modern tbody,
  #page-archive .table-modern tr,
  #page-archive .table-modern td {
    display: block;
    width: 100% !important;
  }
  #page-archive .table-modern tr {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
    margin-bottom: 0.75rem;
    padding: 0.75rem;
  }
  #page-archive .table-modern tr td {
    padding: 0.25rem 0 !important;
    border: none !important;
    background: transparent !important;
  }

  /* Admin table: card treatment */
  #page-admin .table-modern thead {
    display: none;
  }
  #page-admin .table-modern,
  #page-admin .table-modern tbody,
  #page-admin .table-modern tr,
  #page-admin .table-modern td {
    display: block;
    width: 100% !important;
  }
  #page-admin .table-modern tr {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
    margin-bottom: 0.75rem;
    padding: 0.75rem;
  }
  #page-admin .table-modern tr td {
    padding: 0.25rem 0 !important;
    border: none !important;
    background: transparent !important;
  }

  /* Analytics table: card treatment */
  #page-analytics .table-modern thead {
    display: none;
  }
  #page-analytics .table-modern,
  #page-analytics .table-modern tbody,
  #page-analytics .table-modern tr,
  #page-analytics .table-modern td {
    display: block;
    width: 100% !important;
  }
  #page-analytics .table-modern tr {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
    margin-bottom: 0.75rem;
    padding: 0.75rem;
  }
  #page-analytics .table-modern tr td {
    padding: 0.25rem 0 !important;
    border: none !important;
    background: transparent !important;
  }

  /* Kanban: single column with horizontal scroll if needed */
  #kanban-view .grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }
  .kanban-column {
    min-height: auto !important;
  }
  .kanban-col {
    max-height: 60vh;
  }

  /* Modals: full-width with small margins */
  #task-modal > div,
  #subtask-modal > div,
  #confirm-modal > div {
    margin-left: 0.5rem !important;
    margin-right: 0.5rem !important;
    max-width: none !important;
    width: calc(100% - 1rem) !important;
  }

  /* Profile / settings grid collapse */
  #page-profile .grid.grid-cols-1.gap-5.lg\\:grid-cols-\\[1fr_1fr\\] {
    grid-template-columns: 1fr;
  }

  /* Guide page compress */
  .guide-page .mx-auto.max-w-5xl {
    padding: 0;
  }
  .guide-step-header {
    padding: 0.75rem 1rem;
  }
  .guide-step-body {
    padding: 1rem;
  }
  .guide-step-grid {
    grid-template-columns: 1fr;
  }

  /* Admin filter bar stack */
  #page-admin > .flex.items-center.justify-between {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  #page-admin > .flex.items-center.justify-between > .flex.items-center.gap-2 {
    width: 100%;
    flex-wrap: wrap;
  }

  /* Toast: move to center-bottom so it doesn't get cut off */
  #toast-container {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  #toast-container > div {
    max-width: 100%;
    width: 100%;
  }

  /* Reduce font sizes slightly on very small screens */
  body {
    font-size: 14px;
  }
}

/* Very small screens (≤480px) */
@media (max-width: 480px) {
  .page-panel {
    padding: 0.5rem !important;
  }
  header.top-bar-modern {
    padding: 0.5rem;
  }
  #quick-add-btn {
    font-size: 0.75rem;
    padding: 0.5rem 0.75rem;
  }
  .view-btn {
    padding: 0.375rem 0.5rem;
    font-size: 0.7rem;
  }
}

/* ─── Subtask row connector ──────────────────────────────────────────────── */

.subtask-connector {
  position: relative;
}
.subtask-connector::before {
  content: '';
  position: absolute;
  left: 1.25rem;
  top: -0.5rem;
  bottom: 50%;
  width: 1px;
  background: var(--border-default);
}

/* ─── Analytics chart canvas sizing ──────────────────────────────────────── */

#chart-status,
#chart-priority,
#chart-user-growth,
#chart-task-growth {
  width: 100% !important;
  height: 220px !important;
}

/* ─── Theme slide toggle ─────────────────────────────────────────────────── */

.theme-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}
.theme-toggle-track {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 9999px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  transition: background var(--motion-fast) var(--ease-standard), border-color var(--motion-fast) var(--ease-standard);
  flex-shrink: 0;
}
.theme-toggle-wrap:hover .theme-toggle-track {
  border-color: var(--border-focus);
}
.theme-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  transition: transform var(--motion-base) var(--ease-bounce);
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle-thumb i {
  width: 10px;
  height: 10px;
  stroke-width: 2.5;
}
.theme-toggle-wrap.is-dark .theme-toggle-track {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}
.theme-toggle-wrap.is-dark .theme-toggle-thumb {
  transform: translateX(20px);
}
.theme-toggle-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-sidebar);
  transition: color var(--motion-fast) var(--ease-standard);
}

/* Sidebar theme-specific overrides */
:root[data-theme="light"] .app-sidebar .sidebar-brand {
  border-bottom-color: var(--border-subtle);
}
:root[data-theme="light"] .app-sidebar .sidebar-stats {
  border-top-color: var(--border-subtle);
}
:root[data-theme="light"] .app-sidebar .sidebar-theme {
  border-top-color: var(--border-subtle);
}
:root[data-theme="light"] .app-sidebar .sidebar-user {
  border-top-color: var(--border-subtle);
}
/* Light mode sidebar uses dark sidebar vars (same as dark theme) — no overrides needed */
