/* ============================================================
   TASK MANAGEMENT APP — PRODUCTION STYLESHEET
   Award-winning UI/UX: Premium, High-end, Visually Stunning
   ============================================================ */

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


/* ============================================================
   1. CSS CUSTOM PROPERTIES — DESIGN TOKENS
   ============================================================ */

:root {
  /* --- Brand & Primary --- */
  --color-primary:        #4F46E5;
  --color-primary-hover:  #4338CA;
  --color-primary-active: #3730A3;
  --color-primary-subtle: rgba(79, 70, 229, 0.10);
  --color-primary-ring:   rgba(79, 70, 229, 0.35);

  /* --- Accent Teal --- */
  --color-teal:           #14B8A6;
  --color-teal-hover:     #0D9488;
  --color-teal-subtle:    rgba(20, 184, 166, 0.12);

  /* --- Accent Coral --- */
  --color-coral:          #F97316;
  --color-coral-hover:    #EA6C10;
  --color-coral-subtle:   rgba(249, 115, 22, 0.12);

  /* --- Status Colors --- */
  --color-success:        #22C55E;
  --color-success-subtle: rgba(34, 197, 94, 0.12);
  --color-danger:         #EF4444;
  --color-danger-hover:   #DC2626;
  --color-danger-subtle:  rgba(239, 68, 68, 0.12);
  --color-warning:        #F59E0B;
  --color-warning-subtle: rgba(245, 158, 11, 0.12);

  /* --- Backgrounds --- */
  --bg:                   #F8F7FF;
  --surface:              #FFFFFF;
  --surface-2:            #F1F0FB;
  --surface-3:            #E9E8F7;

  /* --- Text --- */
  --text-primary:         #1E1B4B;
  --text-muted:           #6366F1;
  --text-subtle:          #8B8BAE;
  --text-placeholder:     #9CA3AF;
  --text-inverse:         #FFFFFF;

  /* --- Borders --- */
  --border:               rgba(99, 102, 241, 0.12);
  --border-strong:        rgba(99, 102, 241, 0.24);
  --border-focus:         rgba(79, 70, 229, 0.50);

  /* --- Shadows --- */
  --shadow-sm:            0 1px 4px rgba(79, 70, 229, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md:            0 4px 24px rgba(79, 70, 229, 0.10), 0 1.5px 6px rgba(0, 0, 0, 0.06);
  --shadow-lg:            0 8px 40px rgba(79, 70, 229, 0.14), 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-xl:            0 16px 64px rgba(79, 70, 229, 0.18), 0 8px 24px rgba(0, 0, 0, 0.10);
  --shadow-primary:       0 4px 20px rgba(79, 70, 229, 0.40);
  --shadow-teal:          0 4px 20px rgba(20, 184, 166, 0.38);

  /* --- Sidebar --- */
  --sidebar-width:        260px;
  --sidebar-collapsed:    64px;
  --sidebar-bg:           rgba(255, 255, 255, 0.82);
  --sidebar-border:       rgba(99, 102, 241, 0.12);

  /* --- Topbar --- */
  --topbar-height:        68px;

  /* --- Radius --- */
  --radius-sm:            6px;
  --radius-md:            10px;
  --radius-lg:            16px;
  --radius-xl:            20px;
  --radius-pill:          9999px;

  /* --- Spacing --- */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;

  /* --- Typography --- */
  --font-sans:    'Inter', 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-weight-normal:  400;
  --font-weight-medium:  500;
  --font-weight-semibold:600;
  --font-weight-bold:    700;
  --font-weight-extrabold:800;

  /* --- Transitions --- */
  --transition-fast:     150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base:     220ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow:     350ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-sidebar:  0.28s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-theme:    background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;

  /* --- Z-index scale --- */
  --z-sidebar:   100;
  --z-topbar:     90;
  --z-dropdown:  200;
  --z-modal:     300;
  --z-toast:     400;
}

/* --- Dark Mode Token Overrides --- */
[data-theme="dark"] {
  --color-primary:        #6366F1;
  --color-primary-hover:  #7C7FF5;
  --color-primary-active: #4F46E5;
  --color-primary-subtle: rgba(99, 102, 241, 0.15);
  --color-primary-ring:   rgba(99, 102, 241, 0.40);

  --color-teal:           #2DD4BF;
  --color-teal-hover:     #14B8A6;
  --color-teal-subtle:    rgba(45, 212, 191, 0.14);

  --color-coral:          #FB923C;
  --color-coral-hover:    #F97316;
  --color-coral-subtle:   rgba(251, 146, 60, 0.14);

  --color-success:        #4ADE80;
  --color-success-subtle: rgba(74, 222, 128, 0.14);
  --color-danger:         #F87171;
  --color-danger-hover:   #EF4444;
  --color-danger-subtle:  rgba(248, 113, 113, 0.14);

  --bg:                   #0B0F1A;
  --surface:              #131929;
  --surface-2:            #1C2539;
  --surface-3:            #243049;

  --text-primary:         #E8E6FF;
  --text-muted:           #A5B4FC;
  --text-subtle:          #7C85B3;
  --text-placeholder:     #64748B;
  --text-inverse:         #0B0F1A;

  --border:               rgba(99, 102, 241, 0.18);
  --border-strong:        rgba(99, 102, 241, 0.32);
  --border-focus:         rgba(99, 102, 241, 0.55);

  --shadow-sm:            0 1px 4px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.20);
  --shadow-md:            0 4px 24px rgba(0, 0, 0, 0.45), 0 1.5px 6px rgba(0, 0, 0, 0.30);
  --shadow-lg:            0 8px 40px rgba(0, 0, 0, 0.55), 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-xl:            0 16px 64px rgba(0, 0, 0, 0.65), 0 8px 24px rgba(0, 0, 0, 0.40);
  --shadow-primary:       0 4px 20px rgba(99, 102, 241, 0.45);
  --shadow-teal:          0 4px 20px rgba(45, 212, 191, 0.38);

  --sidebar-bg:           rgba(19, 25, 41, 0.88);
  --sidebar-border:       rgba(99, 102, 241, 0.18);
}


/* ============================================================
   2. RESET & BASE
   ============================================================ */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: var(--transition-theme);
  overflow-x: hidden;
}

::selection {
  background-color: var(--color-primary);
  color: #fff;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

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

a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

ul,
ol {
  list-style: none;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-6) 0;
}


/* ============================================================
   3. TYPOGRAPHY
   ============================================================ */

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-bold);
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  transition: color var(--transition-base);
}

h1 { font-size: 2rem;    font-weight: var(--font-weight-extrabold); }
h2 { font-size: 1.5rem;  }
h3 { font-size: 1.25rem; }
h4 { font-size: 1rem;    }
h5 { font-size: 0.9375rem; font-weight: var(--font-weight-semibold); }
h6 { font-size: 0.8125rem; font-weight: var(--font-weight-semibold); letter-spacing: 0.04em; text-transform: uppercase; }

p {
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  transition: color var(--transition-base);
}

p:last-child { margin-bottom: 0; }

code,
kbd,
pre {
  font-family: 'SFMono-Regular', 'Fira Code', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.875em;
}

code {
  background: var(--surface-2);
  color: var(--color-primary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

small { font-size: 0.8125rem; }

strong { font-weight: var(--font-weight-semibold); }

.lead {
  font-size: 1.125rem;
  font-weight: var(--font-weight-normal);
  color: var(--text-subtle);
}


/* ============================================================
   4. SCROLLBARS
   ============================================================ */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}


/* ============================================================
   5. LAYOUT — SHELL
   ============================================================ */

.app-shell {
  display: flex;
  min-height: 100vh;
  position: relative;
}

.main-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-sidebar);
}

.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-collapsed);
}

.page-body {
  flex: 1;
  padding: var(--space-6);
  padding-top: calc(var(--topbar-height) + var(--space-6));
  overflow-y: auto;
}


/* ============================================================
   6. SIDEBAR
   ============================================================ */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--sidebar-border);
  z-index: var(--z-sidebar);
  transition: width var(--transition-sidebar);
  overflow: hidden;
}

.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed);
}

/* Sidebar Logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-4);
  min-height: 72px;
  flex-shrink: 0;
  overflow: hidden;
  text-decoration: none;
}

.sidebar-logo:hover { text-decoration: none; }

.logo-mark {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: var(--radius-md);
  background: none;
  box-shadow: var(--shadow-primary);
}

.logo-text {
  font-size: 1.125rem;
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  letter-spacing: -0.03em;
  white-space: nowrap;
  opacity: 1;
  transition: opacity var(--transition-sidebar), transform var(--transition-sidebar);
}

.sidebar-collapsed .logo-text {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-8px);
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  padding: var(--space-3) var(--space-3);
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section-label {
  font-size: 0.6875rem;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-placeholder);
  padding: var(--space-4) var(--space-3) var(--space-2);
  white-space: nowrap;
  overflow: hidden;
  opacity: 1;
  transition: opacity var(--transition-sidebar);
}

.sidebar-collapsed .nav-section-label {
  opacity: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-subtle);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
  cursor: pointer;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    box-shadow var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--color-primary-subtle);
  text-decoration: none;
}

.nav-item.active {
  color: var(--color-primary);
  background: var(--color-primary-subtle);
  font-weight: var(--font-weight-semibold);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  height: 60%;
  width: 3px;
  background: var(--color-primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.nav-item-icon {
  width: 20px;
  height: 20px;
  min-width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color var(--transition-fast);
}

.nav-item-label {
  opacity: 1;
  transform: translateX(0);
  transition:
    opacity var(--transition-sidebar),
    transform var(--transition-sidebar);
}

.sidebar-collapsed .nav-item-label {
  opacity: 0;
  transform: translateX(-10px);
  pointer-events: none;
}

.nav-badge {
  margin-left: auto;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: var(--font-weight-bold);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  min-width: 20px;
  text-align: center;
  opacity: 1;
  transition: opacity var(--transition-sidebar);
}

.sidebar-collapsed .nav-badge {
  opacity: 0;
}

/* Sidebar Collapse Toggle */
.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-collapsed .sidebar-toggle {
  justify-content: center;
}

.toggle-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-subtle);
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    transform var(--transition-base);
}

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

.toggle-btn .chevron-icon {
  transition: transform var(--transition-base);
}

.sidebar-collapsed .toggle-btn .chevron-icon {
  transform: rotate(180deg);
}

/* Sidebar Bottom User Area */
.sidebar-user {
  padding: var(--space-4) var(--space-3);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  overflow: hidden;
}

.user-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--color-primary), var(--color-teal));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.875rem;
  font-weight: var(--font-weight-bold);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.user-info {
  flex: 1;
  min-width: 0;
  opacity: 1;
  transition: opacity var(--transition-sidebar);
}

.sidebar-collapsed .user-info {
  opacity: 0;
}

.user-name {
  font-size: 0.875rem;
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-subtle);
}

.user-actions {
  display: flex;
  gap: var(--space-1);
  opacity: 1;
  transition: opacity var(--transition-sidebar);
}

.sidebar-collapsed .user-actions {
  opacity: 0;
  pointer-events: none;
}

/* Sidebar tooltip for collapsed state */
.nav-item[data-tooltip] {
  position: relative;
}

.nav-item[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-weight: var(--font-weight-medium);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: 200;
}

.sidebar-collapsed .nav-item[data-tooltip]:hover::after {
  opacity: 1;
}


/* ============================================================
   7. TOP BAR / HEADER
   ============================================================ */

.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  z-index: var(--z-topbar);
  transition:
    left var(--transition-sidebar),
    background var(--transition-base),
    border-color var(--transition-base);
  box-shadow: var(--shadow-sm);
}

.sidebar-collapsed .topbar {
  left: var(--sidebar-collapsed);
}

.topbar-title {
  flex: 1;
  min-width: 0;
}

.page-title {
  font-size: 1.25rem;
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--text-subtle);
  margin-top: 2px;
}

.breadcrumb-item:not(:last-child)::after {
  content: '/';
  margin-left: 6px;
  opacity: 0.5;
}

.breadcrumb-item:last-child {
  color: var(--text-primary);
  font-weight: var(--font-weight-medium);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}


/* ============================================================
   8. CARDS
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
  transition:
    transform var(--transition-base),
    box-shadow var(--transition-base),
    border-color var(--transition-base),
    background var(--transition-base);
  position: relative;
  overflow: hidden;
}

[data-theme="dark"] .card {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

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

.card:active {
  transform: translateY(0);
  box-shadow: var(--shadow-md);
}

.card-sm {
  padding: var(--space-4);
  border-radius: var(--radius-md);
}

.card-flat {
  box-shadow: none;
}

.card-flat:hover {
  transform: none;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  gap: var(--space-3);
}

.card-title {
  font-size: 1rem;
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.card-body { }

.card-footer {
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* Stat Cards */
.stat-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.25rem;
}

.stat-icon.primary { background: var(--color-primary-subtle); color: var(--color-primary); }
.stat-icon.teal    { background: var(--color-teal-subtle);    color: var(--color-teal);    }
.stat-icon.coral   { background: var(--color-coral-subtle);   color: var(--color-coral);   }
.stat-icon.success { background: var(--color-success-subtle); color: var(--color-success); }

.stat-value {
  font-size: 1.75rem;
  font-weight: var(--font-weight-extrabold);
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--text-subtle);
  margin-top: var(--space-1);
}


/* ============================================================
   9. TASK LIST
   ============================================================ */

/* Filter Tab Group */
.filter-tabs {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px;
  gap: 2px;
}

.filter-tab {
  padding: 7px 18px;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  font-weight: var(--font-weight-medium);
  color: var(--text-subtle);
  cursor: pointer;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    box-shadow var(--transition-fast);
  white-space: nowrap;
  border: none;
  background: transparent;
}

.filter-tab:hover {
  color: var(--text-primary);
  background: var(--surface);
}

.filter-tab.active {
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-primary);
  font-weight: var(--font-weight-semibold);
}

/* Search Bar */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input {
  width: 100%;
  padding: 10px var(--space-4) 10px 42px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  color: var(--text-primary);
  outline: none;
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    background var(--transition-base);
}

.search-input::placeholder { color: var(--text-placeholder); }

.search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-ring);
  background: var(--surface);
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-placeholder);
  pointer-events: none;
  font-size: 1rem;
  transition: color var(--transition-fast);
}

.search-bar:focus-within .search-icon {
  color: var(--color-primary);
}

/* Task List Container */
.task-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Task Card */
.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  cursor: default;
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast),
    border-color var(--transition-fast),
    background var(--transition-base),
    opacity var(--transition-base);
  position: relative;
  box-shadow: var(--shadow-sm);
}

.task-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.task-card:hover .task-actions {
  opacity: 1;
  pointer-events: auto;
}

.task-card:hover .drag-handle {
  opacity: 1;
}

/* Drag Handle */
.drag-handle {
  position: absolute;
  left: -2px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-placeholder);
  cursor: grab;
  opacity: 0;
  transition: opacity var(--transition-fast);
  font-size: 0.75rem;
}

.drag-handle:active {
  cursor: grabbing;
}

/* Task Checkbox */
.task-checkbox-wrap {
  flex-shrink: 0;
  padding-top: 2px;
}

.task-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-strong);
  border-radius: 6px;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  position: relative;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    transform var(--transition-fast);
  flex-shrink: 0;
}

.task-checkbox:hover {
  border-color: var(--color-primary);
  transform: scale(1.05);
}

.task-checkbox:checked {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.task-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 2px;
  width: 7px;
  height: 10px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(43deg);
}

.task-checkbox:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-ring);
}

/* Task Body */
.task-body {
  flex: 1;
  min-width: 0;
}

.task-title {
  font-size: 0.9375rem;
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  line-height: 1.4;
  transition:
    color var(--transition-base),
    text-decoration var(--transition-base);
  position: relative;
  display: inline-block;
}

.task-title::after {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 0;
  height: 1.5px;
  background: var(--text-subtle);
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.task-card.completed .task-title {
  color: var(--text-subtle);
  opacity: 0.65;
}

.task-card.completed .task-title::after {
  width: 100%;
}

.task-card.completed {
  opacity: 0.72;
}

.task-description {
  font-size: 0.8125rem;
  color: var(--text-subtle);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 480px;
}

.task-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* Task Actions (revealed on hover) */
.task-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

/* Private Task Style */
.task-card.private {
  background: linear-gradient(
    135deg,
    var(--surface) 0%,
    rgba(20, 184, 166, 0.04) 100%
  );
  border-color: rgba(20, 184, 166, 0.18);
}

[data-theme="dark"] .task-card.private {
  background: linear-gradient(
    135deg,
    var(--surface) 0%,
    rgba(45, 212, 191, 0.06) 100%
  );
}

/* ── Sub-task Nesting ──────────────────────────────── */

.task-item {
  position: relative;
}

.subtask-list {
  position: relative;
  margin-left: 20px;
  padding-left: 20px;
  padding-top: var(--space-2);
  overflow: hidden;
  max-height: 2000px;
  opacity: 1;
  transition: max-height 0.4s ease, opacity 0.25s ease;
}

/* Vertical connector line */
.subtask-list::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 12px;
  width: 2px;
  background: var(--color-primary-subtle);
  border-radius: 1px;
}

.subtask-list.collapsed {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  padding-top: 0;
}

/* Horizontal connector branch to each subtask */
.subtask-list > .task-item {
  position: relative;
}

.subtask-list > .task-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 20px;
  width: 16px;
  height: 2px;
  background: var(--color-primary-subtle);
}

/* Subtask card: compact, muted, no shadow, distinct background */
.subtask-list .task-card {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  box-shadow: none;
  border: 1px solid transparent;
  border-left: 3px solid var(--color-primary-subtle);
}

.subtask-list .task-card:hover {
  transform: none;
  box-shadow: var(--shadow-sm);
  border-color: var(--border);
  border-left-color: var(--color-primary);
}

/* Smaller title and checkbox for subtasks */
.subtask-list .task-title {
  font-size: 0.8625rem;
  font-weight: var(--font-weight-normal);
}

.subtask-list .task-checkbox {
  width: 17px;
  height: 17px;
  border-radius: 5px;
}

.subtask-list .task-checkbox:checked::after {
  left: 3px;
  top: 1px;
  width: 6px;
  height: 9px;
}

.subtask-list .task-description {
  font-size: 0.75rem;
}

.subtask-list .task-meta {
  gap: var(--space-1);
}

.subtask-list .task-meta .badge {
  font-size: 0.625rem;
  padding: 1px 6px;
}

/* Level 2 (sub-sub-tasks): even more compact */
.subtask-list-level-2 .task-card {
  padding: var(--space-1) var(--space-3);
  border-left-color: var(--color-teal-subtle);
}

.subtask-list-level-2 .task-title {
  font-size: 0.8125rem;
}

.subtask-list-level-2::before {
  background: var(--color-teal-subtle);
}

.subtask-list-level-2 > .task-item::before {
  background: var(--color-teal-subtle);
}

/* Spacing between subtask items */
.subtask-list .task-item {
  margin-bottom: var(--space-2);
}

.subtask-list .task-item:last-child {
  margin-bottom: 0;
}

/* Dark mode adjustments */
[data-theme="dark"] .subtask-list .task-card {
  background: var(--surface-2);
  border-left-color: var(--color-primary-subtle);
}

[data-theme="dark"] .subtask-list .task-card:hover {
  border-left-color: var(--color-primary);
}

/* ── Parent Task (has children) ─────────────────────── */

.task-card.has-children {
  border-left: 3px solid var(--color-primary);
  background: linear-gradient(
    135deg,
    var(--surface) 0%,
    rgba(79, 70, 229, 0.03) 100%
  );
}

.task-card.has-children .task-title {
  font-weight: var(--font-weight-semibold);
}

[data-theme="dark"] .task-card.has-children {
  background: linear-gradient(
    135deg,
    var(--surface) 0%,
    rgba(99, 102, 241, 0.06) 100%
  );
}

/* Subtask count badge on parent tasks */
.subtask-count {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-weight: var(--font-weight-medium);
}

.subtask-count i {
  width: 12px;
  height: 12px;
}

/* ── Progress Bar ──────────────────────────────────── */

.task-progress-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  margin-bottom: var(--space-1);
}

.task-progress {
  flex: 1;
  height: 6px;
  background: var(--surface-3);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.task-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-teal));
  border-radius: var(--radius-pill);
  transition: width 0.5s ease;
  min-width: 0;
}

.task-progress-complete .task-progress-bar {
  background: var(--color-success);
  animation: progressPulse 0.8s ease;
}

.task-progress-text {
  font-size: 0.6875rem;
  color: var(--text-subtle);
  white-space: nowrap;
  font-weight: var(--font-weight-medium);
}

@keyframes progressPulse {
  0%   { box-shadow: none; }
  40%  { box-shadow: 0 0 16px rgba(34, 197, 94, 0.55); }
  100% { box-shadow: none; }
}

/* ── Expand/Collapse Toggle ────────────────────────── */

.subtask-toggle i {
  transition: transform 0.25s ease;
}

.subtask-toggle.expanded i {
  transform: rotate(180deg);
}

/* ── Sub-task Badge ────────────────────────────────── */

.badge-subtask {
  background: var(--color-primary-subtle);
  color: var(--color-primary);
}

/* ── Schedule Section in Modal ─────────────────────── */

.schedule-group {
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
  margin-top: var(--space-2);
}

.schedule-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: var(--font-weight-medium);
  user-select: none;
  transition: color var(--transition-fast);
}

.schedule-header:hover {
  color: var(--color-primary);
}

.schedule-header i {
  width: 16px;
  height: 16px;
}

.schedule-chevron {
  margin-left: auto;
  transition: transform 0.25s ease;
}

.schedule-chevron.rotated {
  transform: rotate(180deg);
}

.schedule-fields {
  padding-top: var(--space-2);
}

.schedule-fields.collapsed {
  display: none;
}

.form-row {
  display: flex;
  gap: var(--space-3);
}

.form-row > .flex-1 {
  flex: 1;
  min-width: 0;
}

/* SortableJS States */
.sortable-ghost {
  opacity: 0.35;
  background: var(--color-primary-subtle);
  border: 2px dashed var(--color-primary);
  border-radius: var(--radius-lg);
}

.sortable-chosen {
  box-shadow: var(--shadow-xl) !important;
  transform: rotate(1.5deg) scale(1.02) !important;
  border-color: var(--color-primary) !important;
  z-index: 10;
  cursor: grabbing;
}

.sortable-drag {
  opacity: 0;
}

/* Add Task Button */
.add-task-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 12px var(--space-5);
  background: linear-gradient(135deg, var(--color-primary) 0%, #7C3AED 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  font-size: 0.9375rem;
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  border: none;
  box-shadow: var(--shadow-primary);
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast),
    filter var(--transition-fast);
}

.add-task-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(79, 70, 229, 0.50);
  filter: brightness(1.06);
}

.add-task-btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-primary);
  filter: brightness(0.96);
}

.add-task-btn .plus-icon {
  width: 20px;
  height: 20px;
  background: rgba(255,255,255,0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
}


/* ============================================================
   10. BADGES & TAGS
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  font-size: 0.6rem;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: none;
  border: none;
  color: var(--text-subtle);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Due Date Badge */
.badge-due { color: var(--text-subtle); }
.badge-due .badge-dot { background: var(--text-subtle); }

.badge-due.overdue { color: var(--color-danger); }
.badge-due.overdue .badge-dot { background: var(--color-danger); }

.badge-due.today { color: var(--color-warning); }
.badge-due.today .badge-dot { background: var(--color-warning); }

/* Status Badges */
.badge-active { color: var(--color-primary); }
.badge-active .badge-dot { background: var(--color-primary); }

.badge-completed { color: var(--color-success); }
.badge-completed .badge-dot { background: var(--color-success); }

.badge-private { color: var(--color-teal); }
.badge-private .badge-dot { background: var(--color-teal); }

.badge-calendar { color: var(--color-coral); }
.badge-calendar .badge-dot { background: var(--color-coral); }

.badge-priority-high { color: var(--color-danger); }
.badge-priority-high .badge-dot { background: var(--color-danger); }

.badge-priority-medium { color: var(--color-warning); }
.badge-priority-medium .badge-dot { background: var(--color-warning); }

.badge-priority-low { color: var(--color-success); }
.badge-priority-low .badge-dot { background: var(--color-success); }

.badge-icon {
  font-size: 0.6rem;
  line-height: 1;
}


/* ============================================================
   11. BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 9px var(--space-5);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform var(--transition-fast),
    filter var(--transition-fast);
  position: relative;
  overflow: hidden;
  outline: none;
  user-select: none;
}

.btn:focus-visible {
  box-shadow: 0 0 0 3px var(--color-primary-ring);
}

.btn:active {
  transform: scale(0.975);
}

/* Primary */
.btn-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, #6D28D9 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(79, 70, 229, 0.45);
}

.btn-primary:active {
  filter: brightness(0.95);
  transform: translateY(0) scale(0.975);
  box-shadow: var(--shadow-primary);
}

/* Secondary */
.btn-secondary {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-secondary:hover {
  background: var(--color-primary-subtle);
  border-color: var(--color-primary-hover);
}

/* Danger */
.btn-danger {
  background: linear-gradient(135deg, var(--color-danger) 0%, #DC2626 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.35);
}

.btn-danger:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(239, 68, 68, 0.45);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-subtle);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text-primary);
  border-color: var(--border);
}

/* Teal */
.btn-teal {
  background: linear-gradient(135deg, var(--color-teal) 0%, #0D9488 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-teal);
}

.btn-teal:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(20, 184, 166, 0.48);
}

/* Icon Button */
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.btn-icon.rounded {
  border-radius: var(--radius-pill);
}

/* Sizes */
.btn-sm {
  padding: 6px 14px;
  font-size: 0.8125rem;
  border-radius: var(--radius-md);
}

.btn-sm.btn-icon {
  width: 30px;
  height: 30px;
  padding: 0;
}

.btn-lg {
  padding: 13px var(--space-8);
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

/* Loading Spinner */
.btn.loading {
  pointer-events: none;
  opacity: 0.8;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.btn.loading > * {
  visibility: hidden;
}

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


/* ============================================================
   12. FORMS
   ============================================================ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  font-size: 0.8125rem;
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.form-label .required {
  color: var(--color-danger);
  margin-left: 3px;
}

.form-input,
.form-textarea,
.form-select {
  padding: 10px var(--space-4);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9375rem;
  outline: none;
  width: 100%;
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    background var(--transition-base);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-placeholder);
}

.form-input:hover,
.form-textarea:hover,
.form-select:hover {
  border-color: var(--border-strong);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-ring);
  background: var(--surface);
}

.form-textarea {
  resize: vertical;
  min-height: 96px;
  line-height: 1.6;
}

/* Custom Select */
.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1L6 7L11 1' stroke='%236366F1' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
  cursor: pointer;
}

/* Custom Checkbox */
.checkbox-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
}

.custom-checkbox {
  width: 18px;
  height: 18px;
  min-width: 18px;
  border: 2px solid var(--border-strong);
  border-radius: 5px;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  position: relative;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast);
}

.custom-checkbox:hover {
  border-color: var(--color-primary);
}

.custom-checkbox:checked {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.custom-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 1px;
  width: 6px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(43deg);
}

.custom-checkbox:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-ring);
}

.checkbox-label {
  font-size: 0.9rem;
  color: var(--text-primary);
  user-select: none;
}

/* Error State */
.form-input.error,
.form-textarea.error,
.form-select.error {
  border-color: var(--color-danger);
}

.form-input.error:focus,
.form-textarea.error:focus,
.form-select.error:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25);
}

.form-error {
  font-size: 0.8125rem;
  color: var(--color-danger);
  display: flex;
  align-items: center;
  gap: 5px;
}

.form-hint {
  font-size: 0.8125rem;
  color: var(--text-subtle);
}

/* Input with icon */
.input-with-icon {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-placeholder);
  pointer-events: none;
  transition: color var(--transition-fast);
}

.input-with-icon:focus-within .input-icon {
  color: var(--color-primary);
}

.input-with-icon .form-input {
  padding-left: 42px;
}

/* Time Stepper */
.time-stepper {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.time-stepper-clock {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.time-stepper-clock:hover {
  border-color: var(--border-strong);
}

.time-stepper:not(.active) .time-stepper-clock,
.time-stepper:not(.active) .time-stepper-clear {
  display: none;
}

.time-stepper.active .time-stepper-placeholder {
  display: none;
}

.time-stepper-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.time-stepper-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--text-subtle);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
  padding: 0;
}

.time-stepper-arrow:hover {
  background: var(--color-primary-subtle);
  color: var(--color-primary);
}

.time-stepper-arrow:active {
  background: var(--color-primary-ring);
  color: var(--color-primary-hover);
}

.time-stepper-arrow svg {
  width: 16px;
  height: 16px;
}

.time-stepper-digit {
  font-family: var(--font-sans);
  font-size: 1.35rem;
  font-weight: var(--font-weight-bold);
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  min-width: 36px;
  text-align: center;
  line-height: 1;
  user-select: none;
}

.time-stepper-sep {
  font-size: 1.35rem;
  font-weight: var(--font-weight-bold);
  color: var(--text-subtle);
  user-select: none;
  padding: 0 1px;
  align-self: center;
}

.time-stepper-period {
  font-size: 0.8rem;
  font-weight: var(--font-weight-semibold);
  color: var(--color-primary);
  min-width: 28px;
  letter-spacing: 0.04em;
}

.time-stepper-period-col {
  margin-left: var(--space-1);
}

.time-stepper-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: flex-end;
  width: 22px;
  height: 22px;
  border: none;
  background: var(--surface-3);
  color: var(--text-subtle);
  cursor: pointer;
  border-radius: var(--radius-pill);
  transition: background var(--transition-fast), color var(--transition-fast);
  padding: 0;
}

.time-stepper-clear:hover {
  background: var(--color-danger-subtle);
  color: var(--color-danger);
}

.time-stepper-clear svg {
  width: 12px;
  height: 12px;
}

.time-stepper-placeholder {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: 10px var(--space-4);
  background: var(--surface);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--text-subtle);
  font-size: 0.9rem;
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}

.time-stepper-placeholder:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-subtle);
}

.time-stepper-placeholder svg {
  width: 16px;
  height: 16px;
}


/* ============================================================
   13. MODALS
   ============================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  animation: fadeInBackdrop var(--transition-base) forwards;
}

.modal-backdrop.closing {
  animation: fadeOutBackdrop var(--transition-base) forwards;
}

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

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

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: scaleIn 0.22s cubic-bezier(0.34, 1.40, 0.64, 1) forwards;
  overflow: hidden;
}

.modal-backdrop.closing .modal {
  animation: scaleOut 0.18s cubic-bezier(0.4, 0, 1, 1) forwards;
}

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

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-6) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-subtle);
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    transform var(--transition-fast);
  font-size: 1rem;
  line-height: 1;
}

.modal-close:hover {
  background: var(--color-danger-subtle);
  color: var(--color-danger);
  border-color: rgba(239, 68, 68, 0.22);
  transform: rotate(90deg);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
}

.modal-footer {
  padding: var(--space-4) var(--space-6) var(--space-6);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  flex-shrink: 0;
}

.modal-lg { max-width: 720px; }
.modal-sm { max-width: 400px; }


/* ============================================================
   14. CALENDAR SECTION
   ============================================================ */

.calendar-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  gap: var(--space-4);
  flex-wrap: wrap;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.calendar-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.view-toggle {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
}

.view-btn {
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.8125rem;
  font-weight: var(--font-weight-medium);
  color: var(--text-subtle);
  cursor: pointer;
  transition:
    background var(--transition-fast),
    color var(--transition-fast);
  border: none;
  background: transparent;
}

.view-btn:hover {
  color: var(--text-primary);
}

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

.sync-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--color-teal-subtle);
  color: var(--color-teal);
  border: 1px solid rgba(20, 184, 166, 0.22);
  border-radius: var(--radius-pill);
  font-size: 0.8125rem;
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition:
    background var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
}

.sync-btn:hover {
  background: var(--color-teal);
  color: #fff;
  border-color: transparent;
  transform: translateY(-1px);
  box-shadow: var(--shadow-teal);
}

.sync-btn.syncing .sync-icon {
  animation: spinReverse 1s linear infinite;
}

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

/* FullCalendar Overrides */
#calendar,
.fc {
  font-family: var(--font-sans);
  color: var(--text-primary);
}

.fc .fc-toolbar {
  display: none; /* Use custom toolbar above */
}

.fc .fc-col-header-cell {
  background: var(--surface-2);
  border-color: var(--border);
  font-size: 0.8125rem;
  font-weight: var(--font-weight-semibold);
  color: var(--text-subtle);
  padding: 10px 0;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.fc .fc-daygrid-day {
  background: var(--surface);
  border-color: var(--border);
  transition: background var(--transition-fast);
}

.fc .fc-daygrid-day:hover {
  background: var(--surface-2);
}

.fc .fc-daygrid-day.fc-day-today {
  background: var(--color-primary-subtle);
}

.fc .fc-daygrid-day-number {
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: var(--font-weight-medium);
  padding: 6px 8px;
}

.fc .fc-day-today .fc-daygrid-day-number {
  color: var(--color-primary);
  font-weight: var(--font-weight-bold);
}

.fc .fc-event {
  border-radius: var(--radius-sm);
  border: none;
  padding: 2px 6px;
  font-size: 0.75rem;
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: filter var(--transition-fast), transform var(--transition-fast);
}

.fc .fc-event:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
}

/* App task events */
.fc-event-task {
  background: var(--color-primary);
  color: #fff;
}

/* Google Calendar events */
.fc-event-google {
  background: var(--color-coral);
  color: #fff;
}

.fc-event-google::before {
  content: '●';
  margin-right: 4px;
  font-size: 0.5rem;
  vertical-align: middle;
}

/* Completed (done) events */
.fc-event-done {
  opacity: 0.55;
}

.calendar-event-chip.is-complete .calendar-event-chip-title,
.calendar-event-presence.is-complete .calendar-event-title {
  text-decoration: line-through;
}

.calendar-event-tooltip-pill.is-done {
  background: var(--color-success, #22c55e);
  color: #fff;
}

.fc .fc-scrollgrid {
  border-color: var(--border);
}

.fc .fc-timegrid-axis {
  background: var(--surface-2);
}

.fc .fc-scrollgrid-section > td {
  border-color: var(--border);
}

/* Calendar drop zone highlight */
.fc-day.drag-over {
  background: var(--color-primary-subtle) !important;
  box-shadow: inset 0 0 0 2px var(--color-primary);
  border-radius: var(--radius-sm);
}


/* ============================================================
   15. SPLIT VIEW (MANAGEMENT)
   ============================================================ */

.split-view {
  display: flex;
  height: calc(100vh - var(--topbar-height) - var(--space-12));
  gap: 0;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.split-pane {
  flex: 1;
  min-width: 280px;
  overflow-y: auto;
  background: var(--surface);
}

.split-pane-left {
  border-right: none;
}

.split-pane-right {
  border-left: none;
}

/* Resize Handle */
.resize-handle {
  width: 6px;
  min-width: 6px;
  background: var(--border);
  cursor: col-resize;
  position: relative;
  transition: background var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.resize-handle::before {
  content: '';
  width: 2px;
  height: 32px;
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  transition: background var(--transition-fast), height var(--transition-fast);
}

.resize-handle:hover {
  background: var(--color-primary-subtle);
}

.resize-handle:hover::before {
  background: var(--color-primary);
  height: 48px;
}

.resize-handle:active {
  cursor: col-resize;
  background: var(--color-primary-subtle);
}

.split-pane-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  position: sticky;
  top: 0;
  z-index: 10;
}

.split-pane-body {
  padding: var(--space-4);
}


/* ============================================================
   16. LOGIN PAGE
   ============================================================ */

body.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: linear-gradient(160deg, #dbeafe 0%, #eff6ff 35%, #f8fafc 65%, #e0e7ff 100%);
}

.login-card {
  background: none;
  border: none;
  border-radius: var(--radius-xl);
  box-shadow: none;
  padding: var(--space-10) var(--space-10);
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
  animation: slideInUp 0.45s cubic-bezier(0.34, 1.20, 0.64, 1) forwards;
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}

.login-logo-mark {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: none;
  box-shadow: var(--shadow-primary);
  object-fit: cover;
}

.login-brand {
  font-size: 1.5rem;
  font-weight: var(--font-weight-extrabold);
  color: var(--text-primary);
  letter-spacing: -0.04em;
}

.login-tagline {
  font-size: 0.875rem;
  color: var(--text-subtle);
  text-align: center;
}

.login-title {
  font-size: 1.375rem;
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  letter-spacing: -0.03em;
  margin-bottom: var(--space-2);
}

.login-subtitle {
  font-size: 0.9rem;
  color: var(--text-subtle);
  margin-bottom: var(--space-8);
}

/* Password toggle inside input */
.password-wrap {
  position: relative;
}

.password-wrap .form-input {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-placeholder);
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.password-toggle:hover {
  color: var(--color-primary);
}

.login-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-6) 0;
  color: var(--text-placeholder);
  font-size: 0.8125rem;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-footer {
  margin-top: var(--space-6);
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-subtle);
}


/* ============================================================
   17. THEME TOGGLE
   ============================================================ */

.theme-toggle {
  position: relative;
  width: 62px;
  height: 28px;
  flex-shrink: 0;
}

.theme-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.theme-track {
  position: absolute;
  inset: 0;
  background: var(--surface-3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition:
    background var(--transition-base),
    border-color var(--transition-base);
  overflow: hidden;
}

.theme-track::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-base), background var(--transition-base);
  z-index: 1;
}

.theme-toggle input:checked + .theme-track {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.theme-toggle input:checked + .theme-track::before {
  transform: translateY(-50%) translateX(34px);
  background: #fff;
}

.theme-icon-sun,
.theme-icon-moon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  z-index: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}

.theme-icon-sun  { right: 6px; }
.theme-icon-moon { left: 6px;  }

.theme-toggle input:checked ~ .theme-icon-sun  { opacity: 0; }
.theme-toggle input:not(:checked) ~ .theme-icon-moon { opacity: 0; }

.theme-toggle input:focus-visible + .theme-track {
  box-shadow: 0 0 0 3px var(--color-primary-ring);
}


/* ============================================================
   18. EMPTY STATES
   ============================================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-12) var(--space-8);
  gap: var(--space-4);
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--text-placeholder);
  margin-bottom: var(--space-2);
}

.empty-state-title {
  font-size: 1.125rem;
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.empty-state-desc {
  font-size: 0.9rem;
  color: var(--text-subtle);
  max-width: 320px;
  line-height: 1.6;
}

.empty-state .btn {
  margin-top: var(--space-2);
}


/* ============================================================
   19. LOADING SKELETONS
   ============================================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    var(--surface-3) 50%,
    var(--surface-2) 75%
  );
  background-size: 200% 100%;
  border-radius: var(--radius-md);
  animation: shimmer 1.6s ease-in-out infinite;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 14px;
  border-radius: var(--radius-pill);
  margin-bottom: var(--space-2);
}

.skeleton-text.sm  { height: 11px; }
.skeleton-text.lg  { height: 18px; }
.skeleton-text.w-3\/4 { width: 75%; }
.skeleton-text.w-1\/2 { width: 50%; }
.skeleton-text.w-1\/3 { width: 33%; }

.skeleton-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

.skeleton-card {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
  margin-bottom: var(--space-3);
}

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


/* ============================================================
   20. ANIMATIONS & KEYFRAMES
   ============================================================ */

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

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

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

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

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--color-teal);
  animation: pulse 2s ease-in-out infinite;
  display: inline-block;
}

.animate-fade-in    { animation: fadeIn    0.3s ease forwards; }
.animate-fade-in-up { animation: fadeInUp  0.35s cubic-bezier(0.34, 1.1, 0.64, 1) forwards; }
.animate-slide-up   { animation: slideInUp 0.35s cubic-bezier(0.34, 1.1, 0.64, 1) forwards; }

/* Staggered children */
.stagger-children > *:nth-child(1)  { animation-delay: 0ms;   }
.stagger-children > *:nth-child(2)  { animation-delay: 60ms;  }
.stagger-children > *:nth-child(3)  { animation-delay: 120ms; }
.stagger-children > *:nth-child(4)  { animation-delay: 180ms; }
.stagger-children > *:nth-child(5)  { animation-delay: 240ms; }
.stagger-children > *:nth-child(6)  { animation-delay: 300ms; }


/* ============================================================
   21. DROPDOWN MENUS
   ============================================================ */

.dropdown {
  position: relative;
  display: inline-flex;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  z-index: var(--z-dropdown);
  animation: fadeInUp 0.18s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
  transform-origin: top right;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px var(--space-3);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  cursor: pointer;
  transition:
    background var(--transition-fast),
    color var(--transition-fast);
  text-decoration: none;
}

.dropdown-item:hover {
  background: var(--surface-2);
  color: var(--text-primary);
  text-decoration: none;
}

.dropdown-item.danger {
  color: var(--color-danger);
}

.dropdown-item.danger:hover {
  background: var(--color-danger-subtle);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-2) 0;
}


/* ============================================================
   22. TOAST / NOTIFICATIONS
   ============================================================ */

.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  z-index: var(--z-toast);
  max-width: 360px;
  width: 100%;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  animation: slideInRight 0.30s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
}

.toast.removing {
  animation: slideOutRight 0.25s cubic-bezier(0.4, 0, 1, 1) forwards;
}

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

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  margin-top: 1px;
}

.toast-success .toast-icon { background: var(--color-success-subtle); color: var(--color-success); }
.toast-error   .toast-icon { background: var(--color-danger-subtle);  color: var(--color-danger);  }
.toast-info    .toast-icon { background: var(--color-primary-subtle); color: var(--color-primary); }
.toast-warning .toast-icon { background: var(--color-warning-subtle); color: var(--color-warning); }

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

.toast-title {
  font-size: 0.875rem;
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-bottom: 2px;
}

.toast-message {
  font-size: 0.8125rem;
  color: var(--text-subtle);
  margin: 0;
}

.toast-close {
  color: var(--text-placeholder);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
  flex-shrink: 0;
  font-size: 0.875rem;
}

.toast-close:hover { color: var(--text-primary); }

/* Left accent border */
.toast-success { border-left: 3px solid var(--color-success); }
.toast-error   { border-left: 3px solid var(--color-danger);  }
.toast-info    { border-left: 3px solid var(--color-primary); }
.toast-warning { border-left: 3px solid var(--color-warning); }


/* ============================================================
   23. PROGRESS & INDICATORS
   ============================================================ */

.progress-bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-teal));
  border-radius: var(--radius-pill);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 20px;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35));
  border-radius: inherit;
}

/* Sync indicator */
.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--text-subtle);
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-pill);
  background: var(--color-success);
}

.sync-dot.syncing {
  background: var(--color-teal);
  animation: pulse 1.2s ease-in-out infinite;
}

.sync-dot.error {
  background: var(--color-danger);
}


/* ============================================================
   24. UTILITY CLASSES
   ============================================================ */

/* Screen-reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

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

.text-primary   { color: var(--text-primary); }
.text-muted     { color: var(--text-subtle);  }
.text-accent    { color: var(--color-primary); }
.text-teal      { color: var(--color-teal);   }
.text-coral     { color: var(--color-coral);  }
.text-success   { color: var(--color-success); }
.text-danger    { color: var(--color-danger);  }
.text-sm        { font-size: 0.875rem;  }
.text-xs        { font-size: 0.8125rem; }
.text-lg        { font-size: 1.125rem;  }
.font-medium    { font-weight: var(--font-weight-medium);   }
.font-semibold  { font-weight: var(--font-weight-semibold); }
.font-bold      { font-weight: var(--font-weight-bold);     }
.uppercase      { text-transform: uppercase; letter-spacing: 0.06em; }

/* Flexbox */
.flex         { display: flex; }
.flex-col     { display: flex; flex-direction: column; }
.flex-1       { flex: 1; }
.flex-shrink-0{ flex-shrink: 0; }
.items-start  { align-items: flex-start; }
.items-center { align-items: center; }
.items-end    { align-items: flex-end; }
.justify-start   { justify-content: flex-start; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.flex-wrap    { flex-wrap: wrap; }
.inline-flex  { display: inline-flex; }

/* Grid */
.grid     { display: grid; }
.grid-2   { display: grid; grid-template-columns: repeat(2, 1fr); }
.grid-3   { display: grid; grid-template-columns: repeat(3, 1fr); }
.grid-4   { display: grid; grid-template-columns: repeat(4, 1fr); }

/* Gap */
.gap-1  { gap: var(--space-1);  }
.gap-2  { gap: var(--space-2);  }
.gap-3  { gap: var(--space-3);  }
.gap-4  { gap: var(--space-4);  }
.gap-5  { gap: var(--space-5);  }
.gap-6  { gap: var(--space-6);  }
.gap-8  { gap: var(--space-8);  }

/* Margin */
.mt-1 { margin-top: var(--space-1);  }
.mt-2 { margin-top: var(--space-2);  }
.mt-3 { margin-top: var(--space-3);  }
.mt-4 { margin-top: var(--space-4);  }
.mt-5 { margin-top: var(--space-5);  }
.mt-6 { margin-top: var(--space-6);  }
.mt-8 { margin-top: var(--space-8);  }
.mb-1 { margin-bottom: var(--space-1);  }
.mb-2 { margin-bottom: var(--space-2);  }
.mb-3 { margin-bottom: var(--space-3);  }
.mb-4 { margin-bottom: var(--space-4);  }
.mb-5 { margin-bottom: var(--space-5);  }
.mb-6 { margin-bottom: var(--space-6);  }
.mb-8 { margin-bottom: var(--space-8);  }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }

/* Padding */
.p-0  { padding: 0; }
.p-2  { padding: var(--space-2);  }
.p-3  { padding: var(--space-3);  }
.p-4  { padding: var(--space-4);  }
.p-5  { padding: var(--space-5);  }
.p-6  { padding: var(--space-6);  }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.px-5 { padding-left: var(--space-5); padding-right: var(--space-5); }
.py-2 { padding-top: var(--space-2);  padding-bottom: var(--space-2); }
.py-3 { padding-top: var(--space-3);  padding-bottom: var(--space-3); }
.py-4 { padding-top: var(--space-4);  padding-bottom: var(--space-4); }

/* Width / Height */
.w-full  { width: 100%;  }
.h-full  { height: 100%; }
.min-w-0 { min-width: 0; }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto   { overflow: auto;   }

/* Display */
.hidden { display: none; }
.block  { display: block; }

/* Position */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed    { position: fixed; }

/* Borders */
.border-t { border-top:    1px solid var(--border); }
.border-b { border-bottom: 1px solid var(--border); }
.border   { border:        1px solid var(--border); }
.rounded  { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-pill); }

/* Background */
.bg-surface   { background: var(--surface);   }
.bg-surface-2 { background: var(--surface-2); }

/* Cursor */
.cursor-pointer { cursor: pointer; }
.cursor-default { cursor: default; }
.cursor-grab    { cursor: grab;    }

/* Opacity */
.opacity-0   { opacity: 0;   }
.opacity-50  { opacity: 0.5; }
.opacity-75  { opacity: 0.75; }

/* No wrap */
.whitespace-nowrap { white-space: nowrap; }

/* Aspect ratio */
.aspect-square { aspect-ratio: 1 / 1; }


/* ============================================================
   25. RESPONSIVE BREAKPOINTS
   ============================================================ */

/* 1200px+ wide layout adjustments */
@media (min-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
  .page-body { padding: var(--space-8); padding-top: calc(var(--topbar-height) + var(--space-8)); }
}

/* 1024px breakpoint — split view stacks */
@media (max-width: 1024px) {
  .split-view {
    flex-direction: column;
    height: auto;
  }

  .resize-handle {
    width: 100%;
    height: 6px;
    min-height: 6px;
    cursor: row-resize;
  }

  .resize-handle::before {
    width: 32px;
    height: 2px;
  }

  .split-pane {
    min-width: 0;
    min-height: 300px;
  }

  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* 768px breakpoint — mobile sidebar */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 100%;
    --sidebar-collapsed: 0px;
    --topbar-height: 60px;
  }

  /* Sidebar becomes overlay drawer */
  .sidebar {
    width: 280px;
    transform: translateX(-100%);
    transition: transform var(--transition-base);
    z-index: var(--z-modal);
    border-right: 1px solid var(--border);
  }

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

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(3px);
    z-index: calc(var(--z-modal) - 1);
  }

  .sidebar.open ~ .sidebar-backdrop,
  .sidebar-backdrop.active {
    display: block;
    animation: fadeIn 0.2s ease forwards;
  }

  .main-content {
    margin-left: 0 !important;
  }

  .topbar {
    left: 0 !important;
    padding: 0 var(--space-4);
  }

  .page-body {
    padding: var(--space-4);
    padding-top: calc(var(--topbar-height) + var(--space-4));
  }

  /* Bottom navigation for mobile */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: var(--z-sidebar);
    box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-subtle);
    font-size: 0.6875rem;
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: color var(--transition-fast);
    text-decoration: none;
  }

  .bottom-nav-item.active {
    color: var(--color-primary);
  }

  .bottom-nav-icon {
    font-size: 1.2rem;
  }

  /* Page body padding for bottom nav */
  .page-body {
    padding-bottom: calc(60px + var(--space-4));
  }

  /* Modals full-screen on mobile */
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .modal {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-width: 100%;
    max-height: 92vh;
  }

  /* Search full width */
  .search-bar { width: 100%; }

  /* Filter tabs scrollable */
  .filter-tabs {
    overflow-x: auto;
    max-width: 100%;
  }

  /* Hide desktop elements */
  .hide-mobile { display: none !important; }

  /* Show mobile-only elements */
  .show-mobile { display: flex !important; }

  /* Grid */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  /* Toast position */
  .toast-container {
    bottom: calc(60px + var(--space-4));
    right: var(--space-4);
    left: var(--space-4);
  }
}

/* Bottom nav hidden on desktop */
.bottom-nav { display: none; }

/* Hide mobile-only on desktop */
.show-mobile { display: none; }


/* ============================================================
   26. MOBILE NAV TOGGLE (hamburger)
   ============================================================ */

.hamburger {
  width: 36px;
  height: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  background: none;
  border: none;
  border-radius: var(--radius-md);
  padding: 0;
  transition: background var(--transition-fast);
}

.hamburger:hover {
  background: var(--surface-2);
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform var(--transition-base), opacity var(--transition-fast);
}

.hamburger.active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
  opacity: 0;
}

.hamburger.active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}


/* ============================================================
   27. MISC ELEMENTS
   ============================================================ */

/* Divider with text */
.divider-text {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-placeholder);
  font-size: 0.8125rem;
  margin: var(--space-5) 0;
}

.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Tag Input */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: 6px var(--space-3);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  min-height: 44px;
  align-items: center;
  cursor: text;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.tag-list:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-ring);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  background: var(--color-primary-subtle);
  color: var(--color-primary);
  border-radius: var(--radius-pill);
  font-size: 0.8125rem;
  font-weight: var(--font-weight-medium);
}

.tag-remove {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(79, 70, 229, 0.20);
  color: var(--color-primary);
  font-size: 0.65rem;
  cursor: pointer;
  transition: background var(--transition-fast);
  border: none;
}

.tag-remove:hover {
  background: var(--color-danger);
  color: #fff;
}

/* Tooltip */
[data-tippy-content],
[title] {
  position: relative;
}

/* Avatar group */
.avatar-group {
  display: flex;
}

.avatar-group .user-avatar {
  margin-left: -8px;
  border: 2px solid var(--surface);
}

.avatar-group .user-avatar:first-child {
  margin-left: 0;
}

/* Keyboard shortcut */
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 0.75rem;
  font-family: var(--font-sans);
  font-weight: var(--font-weight-medium);
  color: var(--text-subtle);
  box-shadow: 0 1px 0 var(--border);
}

/* Floating action button */
.fab {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  width: 52px;
  height: 52px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--color-primary) 0%, #7C3AED 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-primary);
  font-size: 1.4rem;
  cursor: pointer;
  border: none;
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast),
    filter var(--transition-fast);
  z-index: calc(var(--z-sidebar) - 1);
}

.fab:hover {
  transform: translateY(-3px) scale(1.06);
  box-shadow: 0 8px 32px rgba(79, 70, 229, 0.55);
}

.fab:active {
  transform: scale(0.96);
}

@media (max-width: 768px) {
  .fab {
    bottom: calc(60px + var(--space-4));
  }
}

/* Section container */
.section {
  margin-bottom: var(--space-8);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  gap: var(--space-4);
}

.section-title {
  font-size: 1.125rem;
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

/* Vertical timeline */
.timeline {
  position: relative;
  padding-left: var(--space-8);
}

.timeline::before {
  content: '';
  position: absolute;
  left: 20px;
  top: 8px;
  bottom: 0;
  width: 2px;
  background: var(--border);
  border-radius: var(--radius-pill);
}

.timeline-item {
  position: relative;
  margin-bottom: var(--space-5);
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: calc(-1 * var(--space-8) + 14px);
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--color-primary);
}

/* ── Flatpickr Custom Theme ─────────────────────────────── */

.flatpickr-calendar {
  font-family: var(--font-sans);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 4px;
  min-width: 320px;
}

.flatpickr-calendar.arrowTop::before,
.flatpickr-calendar.arrowTop::after,
.flatpickr-calendar.arrowBottom::before,
.flatpickr-calendar.arrowBottom::after {
  display: none;
}

.flatpickr-current-month {
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year {
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  font-family: var(--font-sans);
}

.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.flatpickr-months .flatpickr-prev-month svg,
.flatpickr-months .flatpickr-next-month svg {
  fill: var(--text-subtle);
  transition: fill var(--transition-fast);
}

.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover {
  background: var(--surface-2);
}

.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg {
  fill: var(--text-primary);
}

span.flatpickr-weekday {
  color: var(--text-subtle);
  font-weight: var(--font-weight-bold);
}

.flatpickr-day {
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-weight: var(--font-weight-medium);
  border-color: transparent;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.flatpickr-day:hover {
  background: var(--surface-2);
  border-color: transparent;
}

.flatpickr-day.today {
  background: var(--color-primary-subtle);
  color: var(--color-primary);
  border-color: var(--color-primary);
  font-weight: var(--font-weight-bold);
}

.flatpickr-day.today:hover {
  background: var(--color-primary-subtle);
  color: var(--color-primary-hover);
}

.flatpickr-day.selected,
.flatpickr-day.selected:hover,
.flatpickr-day.selected:focus {
  background: var(--color-primary);
  color: var(--text-inverse);
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px var(--color-primary-ring);
}

.flatpickr-day.today.selected,
.flatpickr-day.today.selected:hover {
  background: var(--color-primary);
  color: var(--text-inverse);
  border-color: var(--color-primary);
}

.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
  color: var(--text-placeholder);
}

.flatpickr-day.prevMonthDay:hover,
.flatpickr-day.nextMonthDay:hover {
  background: var(--surface-2);
  border-color: transparent;
}

.flatpickr-day.flatpickr-disabled,
.flatpickr-day.flatpickr-disabled:hover {
  color: var(--text-placeholder);
  opacity: 0.4;
  background: transparent;
  border-color: transparent;
}

.numInputWrapper:hover {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

.numInputWrapper span {
  border: none;
}

.numInputWrapper span.arrowUp::after {
  border-bottom-color: var(--text-subtle);
}

.numInputWrapper span.arrowDown::after {
  border-top-color: var(--text-subtle);
}

.flatpickr-time {
  border-top: 1px solid var(--border);
}

.flatpickr-time input,
.flatpickr-time .flatpickr-am-pm {
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-weight: var(--font-weight-semibold);
}

.flatpickr-time input:hover,
.flatpickr-time input:focus,
.flatpickr-time .flatpickr-am-pm:hover,
.flatpickr-time .flatpickr-am-pm:focus {
  background: var(--surface-2);
}

.flatpickr-time .flatpickr-time-separator {
  color: var(--text-subtle);
}

.flatpickr-time .flatpickr-am-pm {
  color: var(--color-primary);
}

.flatpickr-time .flatpickr-am-pm:hover {
  background: var(--color-primary-subtle);
  color: var(--color-primary-hover);
}

.flatpickr-calendar.noCalendar {
  min-width: 180px;
  padding: 8px;
}

.flatpickr-calendar.noCalendar .flatpickr-time {
  border-top: none;
}

input.flatpickr-input[readonly] {
  background: var(--surface);
  cursor: pointer;
}


/* ── Email Report Section ─────────────────────────── */

.email-report-panel {
  display: flex;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  background: var(--surface);
  height: calc(100vh - var(--topbar-height) - var(--space-12));
  min-height: 400px;
}

.email-report-tasks {
  flex: 1.2;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  min-width: 0;
}

.email-report-tasks-header {
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  flex-shrink: 0;
}

.email-report-tasks-title {
  font-size: 0.875rem;
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.email-report-tasks-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.email-task-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast),
              box-shadow var(--transition-fast), transform var(--transition-fast);
}

.email-task-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.email-task-item:has(input:checked) {
  border-color: var(--color-primary);
  background: var(--color-primary-subtle);
  box-shadow: 0 0 0 1px var(--color-primary-ring);
}

.email-task-item .task-checkbox {
  margin-top: 2px;
  flex-shrink: 0;
}

.email-task-content {
  flex: 1;
  min-width: 0;
}

.email-task-title {
  font-size: 0.9rem;
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  line-height: 1.4;
}

.email-task-desc {
  font-size: 0.8rem;
  color: var(--text-subtle);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-report-compose {
  flex: 0.8;
  display: flex;
  flex-direction: column;
  min-width: 260px;
}

.email-compose-header {
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  background: var(--surface-2);
  flex-shrink: 0;
}

.email-compose-body {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  flex: 1;
}

.email-compose-body .form-group {
  margin-bottom: var(--space-4);
}

.email-compose-body .form-textarea {
  min-height: 72px;
  resize: vertical;
}

.email-selection-count {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  font-size: 0.8125rem;
  font-weight: var(--font-weight-medium);
  color: var(--text-subtle);
  margin-bottom: var(--space-4);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.email-selection-count.has-selection {
  background: var(--color-primary-subtle);
  color: var(--color-primary);
}

.email-compose-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: auto;
}

.email-compose-actions .btn {
  flex: 1;
}

@media (max-width: 1024px) {
  .email-report-panel {
    flex-direction: column;
    min-height: auto;
  }

  .email-report-tasks {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 320px;
  }

  .email-report-compose {
    min-width: 0;
  }
}

/* Print */
@media print {
  .sidebar,
  .topbar,
  .fab,
  .bottom-nav,
  .toast-container {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
  }

  .page-body {
    padding-top: 0 !important;
  }
}
