/* 
 ==========================================================================
   MAGIC TASK MANAGER - PREMIUM STYLESHEET
   Aesthetics: Deep Cosmic Dark, Glassmorphism, Neon Accents, Fluid Motion
 ==========================================================================
*/

/* --- THEME SYSTEM AND CSS VARIABLES --- */
:root {
    /* Magic Dark System Palette */
    --bg-base: #080512;
    --bg-surface: rgba(18, 13, 38, 0.65);
    --bg-card: rgba(28, 21, 56, 0.45);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(139, 92, 246, 0.25);
    
    /* Neon accents */
    --accent-purple: #8B5CF6;
    --accent-purple-glow: rgba(139, 92, 246, 0.5);
    --accent-indigo: #6366F1;
    --accent-emerald: #10B981;
    --accent-emerald-glow: rgba(16, 185, 129, 0.3);
    --accent-rose: #F43F5E;
    --accent-amber: #F59E0B;
    
    /* Typography */
    --text-primary: #F3F4F6;
    --text-secondary: #9CA3AF;
    --text-muted: #6B7280;
    
    /* Telegram Theme Overrides (if available) */
    --tg-bg: var(--bg-base);
    --tg-text: var(--text-primary);
    --tg-hint: var(--text-secondary);
    --tg-link: var(--accent-purple);
    --tg-button: var(--accent-purple);
    --tg-button-text: #FFFFFF;
    
    /* Layout & Shadows */
    --nav-height: 72px;
    --header-height: 64px;
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 8px;
    --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
    --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.15);
}
/* Додайте це на початку файлу, після :root */
body.light-theme {
    --bg-base: #F9FAFB;
    --bg-surface: rgba(255, 255, 255, 0.85);
    --bg-card: rgba(255, 255, 255, 0.95);
    --border-glass: rgba(0, 0, 0, 0.1);
    --border-glow: rgba(139, 92, 246, 0.15);
    
    --text-primary: #111827;
    --text-secondary: #4B5563;
    --text-muted: #9CA3AF;
    
    /* Робимо тіні менш агресивними для світлої теми */
    --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.15);
}
/* Автоматичне визначення теми Telegram */
body.tg-dark {
    --bg-base: #080512;
    --bg-surface: rgba(18, 13, 38, 0.65);
    --bg-card: rgba(28, 21, 56, 0.45);
    --border-glass: rgba(255, 255, 255, 0.08);
    --text-primary: #F3F4F6;
    --text-secondary: #9CA3AF;
    --text-muted: #6B7280;
    --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
}

body.tg-light {
    --bg-base: #F9FAFB;
    --bg-surface: rgba(255, 255, 255, 0.85);
    --bg-card: rgba(255, 255, 255, 0.95);
    --border-glass: rgba(0, 0, 0, 0.1);
    --border-glow: rgba(139, 92, 246, 0.15);
    --text-primary: #111827;
    --text-secondary: #4B5563;
    --text-muted: #9CA3AF;
    --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.15);
}

body.tg-light .bg-glow {
    opacity: 0.05;
}
body.tg-light .app-header {
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

body.tg-light .task-card {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #111827;
}

body.tg-light .task-card .task-description {
    color: #111827;
}

body.tg-light .stat-card {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

body.tg-light .task-tab-btn {
    background: rgba(0, 0, 0, 0.05);
    color: #4B5563;
}

body.tg-light .task-tab-btn.active {
    background: white;
    color: #111827;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

body.tg-light .action-btn {
    background: rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #111827;
}

body.tg-light .bottom-nav {
    background: rgba(255, 255, 255, 0.95);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

body.tg-light .nav-btn {
    color: #6B7280;
}

body.tg-light .nav-btn.active {
    color: #8B5CF6;
}

body.tg-light .search-bar {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

body.tg-light .search-bar input {
    color: #111827;
}

body.tg-light .view-title {
    color: #111827;
}
/* Вимикаємо "космічні" світіння у світлій темі для чистоти інтерфейсу */
body.light-theme .bg-glow {
    opacity: 0.05; 
}
/* Telegram Native Theme Auto-Mapping */
/* СТАЛО — tg-light має пріоритет над telegram-theme: */
body.telegram-theme:not(.tg-light) {
    --bg-base: var(--tg-theme-bg-color, #080512);
    --text-primary: var(--tg-theme-text-color, #F3F4F6);
    --text-secondary: var(--tg-theme-hint-color, #9CA3AF);
    --accent-purple: var(--tg-theme-button-color, #8B5CF6);
    --bg-surface: rgba(from var(--tg-theme-secondary-bg-color, #120D26) r g b / 0.6);
}

/* --- RESET & BASE STYLES --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    overflow-x: hidden;
    position: relative;
    font-size: 15px;
    line-height: 1.5;
}

html {
    height: -webkit-fill-available;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.2);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.4);
}

/* --- PRELOADER ANIMATION --- */
.preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #080512;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

body:not(.loading) .preloader {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.05);
}

.loader-content {
    text-align: center;
}

.magic-sparkle {
    font-size: 48px;
    animation: bounceSparkle 1.8s infinite ease-in-out;
    margin-bottom: 12px;
}

.loader-title {
    font-family: 'Outfit', sans-serif;
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, #FFF 30%, var(--accent-purple) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
}

.loader-subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 24px;
}

.progress-bar {
    width: 140px;
    height: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    margin: 0 auto;
    overflow: hidden;
}

.progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-indigo), var(--accent-purple));
    border-radius: 10px;
    animation: fillProgress 1.5s infinite ease-in-out;
}

@keyframes bounceSparkle {
    0%, 100% { transform: translateY(0) scale(1) rotate(0deg); text-shadow: 0 0 10px rgba(139, 92, 246, 0.2); }
    50% { transform: translateY(-12px) scale(1.1) rotate(15deg); text-shadow: 0 0 25px var(--accent-purple-glow); }
}

@keyframes fillProgress {
    0% { width: 0%; }
    50% { width: 80%; }
    100% { width: 100%; }
}

/* --- DECORATIVE GLOW BACKGROUNDS --- */
.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    pointer-events: none;
    opacity: 0.28;
}
.bg-glow-1 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, var(--accent-purple) 0%, transparent 80%);
    top: -50px;
    right: -100px;
    animation: drift 15s infinite alternate ease-in-out;
}
.bg-glow-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--accent-indigo) 0%, transparent 80%);
    bottom: 50px;
    left: -150px;
    animation: drift 20s infinite alternate-reverse ease-in-out;
}
.bg-glow-3 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--accent-emerald) 0%, transparent 80%);
    top: 40%;
    right: -100px;
    opacity: 0.12;
}

@keyframes drift {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(40px, 30px) scale(1.15); }
}

/* --- APP CONTAINERS --- */
.app-container {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: var(--nav-height);
}

/* --- HEADER STYLES --- */
.app-header {
    height: var(--header-height);
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-glass);
    position: sticky;
    top: 0;
    z-index: 100;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-glow);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    color: white;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

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

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

.action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.action-btn:active {
    transform: scale(0.92);
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--accent-purple);
}

.action-btn svg {
    width: 16px;
    height: 16px;
}

/* --- APP MAIN & VIEWS --- */
.app-content {
    flex: 1;
    padding: 20px;
    padding-bottom: 110px;
    overflow-y: auto;
}

.app-view {
    display: none;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1), transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-view.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.view-header {
    margin-bottom: 20px;
}

.view-header-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.view-header-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.35);
}

.view-title {
    font-family: 'Outfit', sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Glassmorphism Panel Wrapper */
.glass-panel {
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-premium);
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.glass-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
}

.panel-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
    margin-bottom: 16px;
}

/* --- VIEW 1: TASKS DASHBOARD --- */
.task-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-top: 14px;
}

.task-tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-secondary);
    padding: 10px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.task-tab-btn.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(139, 92, 246, 0.25));
    color: white;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
}

/* Stats Ribbon */
.stats-ribbon {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

/* Скоупимо під .stats-ribbon: клас .stat-card далі у файлі повторно
   використовується для іншої (глобальної) статистики в Налаштуваннях —
   без цього скоупу пізніше правило переб'є цей блок. */
.stats-ribbon .stat-card {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 14px 6px;
    text-align: center;
    box-shadow: var(--shadow-premium);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    opacity: 0;
    transform: translateY(8px);
    animation: statCardIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.stats-ribbon .stat-card:nth-child(1) { animation-delay: 0.02s; }
.stats-ribbon .stat-card:nth-child(2) { animation-delay: 0.07s; }
.stats-ribbon .stat-card:nth-child(3) { animation-delay: 0.12s; }
.stats-ribbon .stat-card:nth-child(4) { animation-delay: 0.17s; }
@keyframes statCardIn {
    to { opacity: 1; transform: translateY(0); }
}

.stats-ribbon .stat-card:active {
    transform: translateY(-2px);
}

.stat-icon {
    font-size: 17px;
    line-height: 1;
    margin-bottom: 2px;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
}

.stat-val {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    font-weight: 700;
}

.stat-lbl {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.active-tasks { border-color: rgba(139, 92, 246, 0.18); }
.active-tasks .stat-val { color: var(--accent-purple); }
.active-tasks:active { box-shadow: 0 6px 18px rgba(139, 92, 246, 0.2); border-color: rgba(139, 92, 246, 0.4); }

.overdue-tasks { border-color: rgba(244, 63, 94, 0.18); }
.overdue-tasks .stat-val { color: var(--accent-rose); }
.overdue-tasks:active { box-shadow: 0 6px 18px rgba(244, 63, 94, 0.2); border-color: rgba(244, 63, 94, 0.4); }

.done-tasks { border-color: rgba(16, 185, 129, 0.18); }
.done-tasks .stat-val { color: var(--accent-emerald); }
.done-tasks:active { box-shadow: 0 6px 18px rgba(16, 185, 129, 0.2); border-color: rgba(16, 185, 129, 0.4); }

.unread-comments-stat { border-color: rgba(244, 63, 94, 0.18); }
.unread-comments-stat .stat-val { color: var(--accent-rose); }
.unread-comments-stat:active { box-shadow: 0 6px 18px rgba(244, 63, 94, 0.2); border-color: rgba(244, 63, 94, 0.4); }

.stat-card-selected {
    border-color: rgba(139, 92, 246, 0.6) !important;
    background: rgba(139, 92, 246, 0.1) !important;
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.25), 0 6px 18px rgba(139, 92, 246, 0.2) !important;
}

.stat-filter-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(139, 92, 246, 0.18));
    border: 1px solid rgba(139, 92, 246, 0.35);
    border-radius: 12px;
    padding: 9px 14px;
    margin: -10px 0 16px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    animation: cardEntrance 0.2s ease;
}
.stat-filter-chip-x {
    color: var(--text-secondary);
    font-size: 13px;
    flex-shrink: 0;
}

/* --- МІНІ-КАЛЕНДАР: МУЛЬТИВИБІР ДАТ ЗМІНИ / ПЕРЕГЛЯД ДНІВ --- */
.mini-cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.mini-cal-nav {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mini-cal-nav:active { transform: scale(0.92); background: rgba(139, 92, 246, 0.18); }
.mini-cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 4px;
}
.mini-cal-weekdays span {
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}
.mini-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}
.mini-cal-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}
.mini-cal-day:active { transform: scale(0.9); }
.mini-cal-day.past {
    opacity: 0.3;
    cursor: default;
    background: transparent;
}
.mini-cal-dots {
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 2px;
}
.mini-cal-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    display: block;
}

.shift-color-swatch {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease;
}
.shift-color-swatch:active { transform: scale(0.9); }
.shift-color-swatch.selected {
    border-color: white;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Search filtering box */
.search-filter-box {
    margin-bottom: 16px;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input-wrapper input {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 12px 12px 12px 42px;
    color: white;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.search-input-wrapper input:focus {
    border-color: var(--accent-purple);
    background: rgba(139, 92, 246, 0.05);
    box-shadow: var(--shadow-glow);
}

/* Tasks List Empty States */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    background: var(--bg-surface);
    border: 1px dashed var(--border-glass);
    border-radius: var(--radius-lg);
}

.empty-emoji {
    font-size: 44px;
    display: block;
    margin-bottom: 10px;
    animation: floatEmoji 3s infinite ease-in-out;
}

@keyframes floatEmoji {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.empty-state h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    margin-bottom: 4px;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 12px;
}

/* Task Cards */
.task-card {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-premium);
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: cardEntrance 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.task-card:active {
    transform: translateY(-1px);
}

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

.task-card.high-prio { border-left: 3.5px solid var(--accent-rose); }
.task-card.med-prio { border-left: 3.5px solid var(--accent-amber); }
.task-card.low-prio { border-left: 3.5px solid var(--accent-emerald); }

.task-card.completed {
    opacity: 0.65;
    border-left-color: var(--text-muted);
}

.task-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
    gap: 8px;
}

.task-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.task-assignee {
    font-size: 13px;
    font-weight: 600;
    color: white;
}

.task-assignee span {
    color: var(--accent-purple);
}

.task-edit-btn {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.07);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    position: relative;
}

.task-edit-btn:active {
    background: rgba(139, 92, 246, 0.18);
    border-color: rgba(139, 92, 246, 0.35);
    transform: scale(0.94);
}

.unread-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 16px;
    height: 16px;
    padding: 0 3px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent-rose), #fb7185);
    color: white;
    font-size: 9px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 2px 6px rgba(244, 63, 94, 0.5);
    border: 1.5px solid var(--bg-surface, #1a1f2e);
    animation: unreadPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes unreadPop {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

.task-meta-badge {
    font-size: 9px;
    text-transform: uppercase;
    font-weight: 700;
    padding: 4px 10px 4px 8px;
    border-radius: 20px;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.task-meta-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.high-prio .task-meta-badge { background: rgba(244, 63, 94, 0.15); color: var(--accent-rose); }
.med-prio .task-meta-badge { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.low-prio .task-meta-badge { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.task-card.completed .task-meta-badge { background: rgba(255, 255, 255, 0.08); color: var(--text-muted); }

.task-desc-content {
    font-size: 13px;
    color: var(--text-primary);
    word-break: break-word;
    margin-bottom: 12px;
    white-space: pre-line;
}

.task-card.completed .task-desc-content {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.task-footer-info {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 11px;
    color: var(--text-secondary);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 10px;
    margin-bottom: 12px;
}

.task-deadline,
.task-regularity {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 4px 9px;
    border-radius: 20px;
}

.task-deadline.overdue {
    color: var(--accent-rose);
    font-weight: 600;
    background: rgba(244, 63, 94, 0.08);
    border-color: rgba(244, 63, 94, 0.2);
}

/* Task card control buttons */
.task-controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.task-ctrl-btn {
    padding: 9px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border-glass);
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

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

.btn-ctrl-progress {
    background: rgba(139, 92, 246, 0.1);
    color: var(--accent-purple);
    border-color: rgba(139, 92, 246, 0.2);
}
.btn-ctrl-progress:active { background: rgba(139, 92, 246, 0.2); }

.btn-ctrl-complete {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-emerald);
    border-color: rgba(16, 185, 129, 0.2);
}
.btn-ctrl-complete:active { background: rgba(16, 185, 129, 0.2); }

.btn-ctrl-stop {
    background: rgba(244, 63, 94, 0.05);
    color: var(--accent-rose);
    border-color: rgba(244, 63, 94, 0.1);
}
.btn-ctrl-stop:active { background: rgba(244, 63, 94, 0.15); }

.btn-ctrl-delete {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    grid-column: span 2;
}
.btn-ctrl-delete:active { background: rgba(244, 63, 94, 0.15); color: var(--accent-rose); border-color: rgba(244, 63, 94, 0.2); }

/* --- FORM GENERAL DESIGN --- */
.magic-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-input {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    color: white;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-input:focus {
    border-color: var(--accent-purple);
    background: rgba(139, 92, 246, 0.03);
    box-shadow: var(--shadow-glow);
}

.form-textarea {
    resize: vertical;
    min-height: 70px;
    /* --tg-vh встановлюється з JS через tg.viewportHeight (реальна
       висота вьюпорту Mini App у Telegram, включно з fullscreen-режимом)
       — надійніше за звичайні vh-одиниці, які не завжди коректно
       відстежують розгортання/згортання застосунку в Telegram. */
    max-height: calc(var(--tg-vh, 100vh) * 0.5);
}

/* Поле опису замовлення — найчастіше довгий текст, тож даємо йому одразу
   трохи більше місця за замовчуванням, ніж іншим текстовим полям. */
#custom-desc {
    min-height: 120px;
}

/* Кастомний вигляд <select>: ховаємо нативну стрілку/чекбокс-іконку ОС
   і малюємо свій шеврон у мові дизайну застосунку. Сам розкритий список
   опцій все одно малює ОС/браузер (це неможливо переозначити через CSS),
   але "згорнутий" стан тепер виглядає консистентно з рештою UI. */
.select-wrapper {
    position: relative;
}
.select-wrapper select.form-input {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 42px;
    cursor: pointer;
}
.select-wrapper select.form-input::-ms-expand {
    display: none;
}
.select-chevron {
    position: absolute;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    pointer-events: none;
    transition: color 0.2s ease, transform 0.2s ease;
}
.select-wrapper:focus-within .select-chevron {
    color: var(--accent-purple);
}

.form-help {
    font-size: 11px;
    color: var(--text-secondary);
}

.view-header-split {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    color: var(--accent-purple);
    font-size: 17px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}
.history-icon-btn:active {
    transform: scale(0.92);
    background: rgba(139, 92, 246, 0.2);
}

.dashed-add-btn {
    padding: 11px;
    border-radius: 12px;
    width: 100%;
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    border: 1.5px dashed var(--border-glass);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.dashed-add-btn:active {
    border-color: rgba(139, 92, 246, 0.4);
    background: rgba(139, 92, 246, 0.06);
    color: var(--accent-purple);
}

.ref-upload-zone {
    border: 1.5px dashed var(--border-glass);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
}
.ref-upload-zone:active {
    border-color: rgba(139, 92, 246, 0.4);
    background: rgba(139, 92, 246, 0.06);
}
.ref-upload-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 28px 16px;
    text-align: center;
}
.ref-upload-icon {
    font-size: 28px;
    opacity: 0.7;
}
.ref-upload-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}
.ref-upload-preview {
    display: flex;
    flex-direction: column;
}
.ref-upload-preview img,
.ref-upload-preview video {
    width: 100%;
    max-height: 220px;
    object-fit: contain;
    background: rgba(0, 0, 0, 0.3);
    display: block;
}
.ref-upload-preview-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
}
.ref-upload-preview-info span {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ref-upload-remove {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    border: 1px solid rgba(244, 63, 94, 0.25);
    background: rgba(244, 63, 94, 0.12);
    color: var(--accent-rose);
    font-size: 13px;
    cursor: pointer;
}
.ref-dd-thumb {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    background: rgba(139, 92, 246, 0.14);
    object-fit: cover;
}
.ref-danger-btn {
    width: 100%;
    margin-top: 18px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(244, 63, 94, 0.08);
    border: 1px solid rgba(244, 63, 94, 0.2);
    color: var(--accent-rose);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.ref-danger-btn:active {
    background: rgba(244, 63, 94, 0.16);
}

.model-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-left: 3px solid var(--model-accent, var(--accent-purple));
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.model-card:active {
    transform: scale(0.985);
    box-shadow: 0 0 0 1px var(--model-accent, var(--accent-purple)), 0 8px 24px -8px var(--model-accent-glow, rgba(139, 92, 246, 0.35));
}
.model-avatar {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, var(--model-accent, var(--accent-purple)), var(--model-accent-2, var(--accent-indigo)));
    box-shadow: 0 4px 14px -4px var(--model-accent-glow, rgba(139, 92, 246, 0.5));
}
.model-card-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.model-card-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}
.model-card-chevron {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 20px;
    flex-shrink: 0;
}

.model-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-top: 2px solid var(--section-accent, var(--accent-purple));
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
}
.model-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.model-section-icon {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    line-height: 38px;
    text-align: center;
    background: linear-gradient(135deg, var(--section-accent, var(--accent-purple)), var(--section-accent-2, var(--accent-indigo)));
    box-shadow: 0 4px 12px -4px var(--section-accent, var(--accent-purple));
}
.model-section-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}
.model-section-header span {
    font-size: 11.5px;
    color: var(--text-secondary);
    display: block;
    margin-top: 1px;
}

.orphan-route-card {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.orphan-route-assign-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.orphan-route-assign-row select {
    flex: 1;
    min-width: 0;
}
.orphan-route-assign-row button {
    flex-shrink: 0;
    width: auto;
    margin: 0;
    padding: 0 16px;
    height: 40px;
}

.media-drop-zone {
    border: 2px dashed var(--border-glass);
    border-radius: 14px;
    padding: 20px 16px;
    text-align: center;
    transition: border-color 0.2s ease, background 0.2s ease;
    background: rgba(255, 255, 255, 0.015);
}
.media-drop-zone-hint {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 4px;
    cursor: pointer;
}

.form-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.assign-self-btn {
    background: none;
    border: none;
    color: var(--accent-purple);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    transition: opacity 0.2s ease;
}
.assign-self-btn:active { opacity: 0.6; }

.file-upload-row { margin-top: 8px; display: flex; align-items: center; gap: 8px; }
.file-upload-input { display: none; }
.file-upload-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    border: 1px dashed var(--border-glass);
    transition: all 0.2s ease;
    max-width: 100%;
    overflow: hidden;
}
.file-upload-label:active {
    border-color: rgba(139, 92, 246, 0.4);
    background: rgba(139, 92, 246, 0.06);
}
.file-upload-label.file-selected {
    color: var(--accent-purple);
    border-style: solid;
    border-color: rgba(139, 92, 246, 0.35);
    background: rgba(139, 92, 246, 0.08);
}
.file-upload-label.file-selected span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-remove-btn {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid rgba(244, 63, 94, 0.25);
    background: rgba(244, 63, 94, 0.12);
    color: var(--accent-rose);
    font-size: 13px;
    cursor: pointer;
}

/* Custom autocomplete dropdown */
.custom-select-wrapper {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    background: #141029;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    max-height: 180px;
    overflow-y: auto;
    z-index: 50;
    display: none;
    box-shadow: var(--shadow-premium);
}

.autocomplete-dropdown.active {
    display: block;
}

.dropdown-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s ease;
}

.dropdown-item:hover {
    background: rgba(139, 92, 246, 0.15);
    color: white;
}

/* Stepper Component */
.reminders-stepper {
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 4px;
    width: fit-content;
}

.step-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.step-btn:hover { background: rgba(255, 255, 255, 0.05); }
.step-btn:active { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }

.step-val {
    width: 44px;
    text-align: center;
    font-weight: 700;
    font-size: 14px;
}

/* Submit Buttons */
.submit-btn {
    position: relative;
    width: 100%;
    background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
    border: none;
    border-radius: var(--radius-md);
    padding: 14px;
    color: white;
    font-size: 15px;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.25);
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    justify-content: center;
    align-items: center;
}

.submit-btn:hover {
    box-shadow: 0 4px 25px rgba(139, 92, 246, 0.4);
    transform: translateY(-1px);
}

.submit-btn:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 2px 10px rgba(139, 92, 246, 0.2);
}

.btn-glow {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
    transition: all 0.5s ease;
    animation: buttonGlow 3s infinite linear;
}

@keyframes buttonGlow {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Priority Badges */
.priority-badges {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.prio-badge input[type="radio"],
.regularity-chips input[type="radio"] {
    display: none;
}

.prio-badge {
    cursor: pointer;
}

.prio-badge .badge-inner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 4px;
    border-radius: var(--radius-md);
    font-size: 11px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    transition: all 0.2s ease;
}

.badge-low input:checked + .badge-inner { background: rgba(16, 185, 129, 0.1); border-color: var(--accent-emerald); color: var(--accent-emerald); }
.badge-medium input:checked + .badge-inner { background: rgba(245, 158, 11, 0.1); border-color: var(--accent-amber); color: var(--accent-amber); }
.badge-high input:checked + .badge-inner { background: rgba(244, 63, 94, 0.1); border-color: var(--accent-rose); color: var(--accent-rose); }

/* Regularity chips */
.regularity-chips {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.reg-chip { cursor: pointer; }
.reg-chip .chip-inner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 4px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    transition: all 0.2s ease;
}
.reg-chip input:checked + .chip-inner {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
    border-color: rgba(139, 92, 246, 0.4);
    color: white;
    box-shadow: 0 3px 10px rgba(139, 92, 246, 0.15);
}

/* --- PREMIUM CALENDAR PICKER --- */
.datetime-picker-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}
.datetime-picker-trigger:active { border-color: var(--accent-purple); background: rgba(139, 92, 246, 0.03); }
.picker-value { color: white; font-weight: 500; }
.picker-icon { width: 16px; height: 16px; color: var(--text-secondary); }

.calendar-modal {
    background: #110d24;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-top: 10px;
    box-shadow: var(--shadow-premium);
    display: none;
    flex-direction: column;
    gap: 12px;
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.calendar-modal.active { display: flex; }

/* ВИПРАВЛЕНО: Окрема анімація для центрованого модального вікна календаря */
@keyframes slideUpCenter {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

#calendar-picker-modal {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 420px;
    z-index: 9999;
    margin-top: 0;
    /* Вимикаємо базову анімацію .calendar-modal, яка збиває центрування */
    animation: none; 
}

#calendar-picker-modal.active {
    display: flex;
    /* Застосовуємо нову анімацію, яка враховує translateX(-50%) */
    animation: slideUpCenter 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Легка підказка, що є горизонтальний скрол, якщо контент не влазить */
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 16px), transparent 100%);
    mask-image: linear-gradient(90deg, #000 calc(100% - 16px), transparent 100%);
}
.ids-table {
    width: 100%;
    min-width: 380px;
    table-layout: fixed;
    border-collapse: collapse;
    text-align: left;
    color: white;
}
.ids-table col.col-name { width: 46%; }
.ids-table col.col-type { width: 20%; }
.ids-table col.col-id { width: 34%; }
.ids-table th, .ids-table td {
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.9rem;
}
.ids-table th {
    color: var(--text-secondary);
    font-weight: 500;
}
/* Назва може бути довгою (з емодзі) — обрізаємо в один рядок замість
   переносу на два, який виштовхує колонку ID за межі екрана */
.ids-table td:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ids-table td:last-child {
    white-space: nowrap;
}
.copyable {
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 3px 8px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 12px;
    display: inline-block;
    white-space: nowrap;
    vertical-align: middle;
}
.copyable:hover, .copyable:active {
    color: var(--accent-purple);
    background: rgba(139, 92, 246, 0.12);
    border-color: rgba(139, 92, 246, 0.25);
}

/* --- REFERENCE ITEMS (База референсів) --- */
.reference-item {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    opacity: 0;
    transform: translateY(6px);
    animation: cardEntrance 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.reference-item:active { transform: translateY(-1px); }
.reference-item-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}
.reference-icon {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    background: rgba(139, 92, 246, 0.14);
    border: 1px solid rgba(139, 92, 246, 0.18);
}
.reference-thumb {
    object-fit: cover;
    background: rgba(255, 255, 255, 0.04);
}
.reference-category {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: capitalize;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
}
.reference-topic {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.reference-delete-btn {
    background: rgba(244, 63, 94, 0.08);
    border: 1px solid rgba(244, 63, 94, 0.15);
    color: var(--accent-rose);
    font-size: 13px;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}
.reference-delete-btn:active { transform: scale(0.88); background: rgba(244, 63, 94, 0.18); }

/* --- ЖУРНАЛ ДІЙ (AUDIT LOG) --- */
.audit-log-item {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    opacity: 0;
    transform: translateY(6px);
    animation: cardEntrance 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.audit-log-icon {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    background: rgba(244, 63, 94, 0.12);
    border: 1px solid rgba(244, 63, 94, 0.18);
}
.audit-log-body {
    min-width: 0;
    flex: 1;
}
.audit-log-desc {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
}
.audit-log-desc b {
    color: var(--accent-purple);
    font-weight: 700;
}
.audit-log-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* --- КОМЕНТАРІ ДО ЗАДАЧІ --- */
.comment-bubble-row {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 10px;
}
.comment-bubble-row.mine {
    justify-content: flex-end;
}
.comment-bubble {
    max-width: 78%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: 14px 14px 14px 4px;
    padding: 9px 12px;
}
.comment-bubble-row.mine .comment-bubble {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(139, 92, 246, 0.25));
    border-color: rgba(139, 92, 246, 0.3);
    border-radius: 14px 14px 4px 14px;
}
.comment-author {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-purple);
    margin-bottom: 2px;
}
.comment-text {
    font-size: 13px;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}
.comment-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 3px;
    text-align: right;
}
.comment-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px calc(env(safe-area-inset-bottom, 0px) + 14px);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.comment-input-row .form-input {
    flex: 1;
    padding: 10px 14px;
}
.comment-send-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
    color: white;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.3);
    transition: transform 0.2s ease;
}
.comment-send-btn:active {
    transform: scale(0.92);
}

.stat-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.1);
}
.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    text-shadow: 0 0 10px rgba(111, 66, 193, 0.3);
}
.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.stat-card.complete .stat-value { color: #10b981; }
.stat-card.staff .stat-value { color: #3b82f6; }
.stat-card.bridges .stat-value { color: #f59e0b; }
.stat-card.overdue .stat-value { color: var(--accent-rose); }

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

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.calendar-nav-btn {
    background: transparent;
    border: none;
    color: var(--accent-purple);
    font-size: 14px;
    padding: 6px 12px;
    cursor: pointer;
}
.calendar-month-year { font-size: 14px; font-weight: 700; color: white; font-family: 'Outfit', sans-serif; }

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    margin-bottom: 6px;
}
.weekday-lbl { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; padding: 4px 0; }

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    text-align: center;
}
.calendar-day {
    padding: 8px 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s ease;
}
.calendar-day:hover { background: rgba(255, 255, 255, 0.05); }
.calendar-day.empty { pointer-events: none; }
.calendar-day.selected {
    background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
    color: white;
    box-shadow: 0 4px 10px rgba(139, 92, 246, 0.2);
}
.calendar-day.today {
    border: 1px solid var(--accent-purple);
    color: var(--accent-purple);
}
.calendar-day.today.selected { color: white; }

.calendar-time-picker {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 12px;
    font-size: 13px;
}
.time-inputs { display: flex; align-items: center; gap: 4px; }
.time-inputs input {
    width: 48px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: 6px;
    padding: 6px;
    color: white;
    text-align: center;
    outline: none;
    font-size: 13px;
}

.calendar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 6px;
}
.calendar-btn {
    padding: 10px;
    font-size: 12px;
    font-weight: 700;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: none;
}
.calendar-btn.btn-secondary { background: rgba(255, 255, 255, 0.05); color: var(--text-secondary); }
.calendar-btn.btn-primary { background: var(--accent-purple); color: white; }

/* --- VIEW 3: STAFF & TEAM PANEL --- */
.staff-action-panel { padding-bottom: 24px; }
.staff-action-panel h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; font-family: 'Outfit', sans-serif; }
.input-row { display: flex; gap: 10px; }
.add-btn {
    background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 0 18px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.3);
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.add-btn:active { transform: scale(0.95); box-shadow: 0 2px 8px rgba(139, 92, 246, 0.2); }

.staff-section { margin-top: 10px; }
.section-subtitle { font-family: 'Outfit', sans-serif; font-size: 15px; font-weight: 700; margin-bottom: 12px; color: var(--text-primary); }

.staff-member-card {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-premium);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translateY(8px);
    animation: cardEntrance 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.staff-member-card:active { transform: translateY(-1px); }
.staff-member-info { display: flex; align-items: center; gap: 10px; }
.staff-member-info .avatar { width: 36px; height: 36px; font-size: 13px; }
.staff-name { font-size: 13px; font-weight: 600; }
.staff-delete-btn {
    background: rgba(244, 63, 94, 0.08);
    border: 1px solid rgba(244, 63, 94, 0.15);
    color: var(--accent-rose);
    font-size: 13px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}
.staff-delete-btn:active { transform: scale(0.88); background: rgba(244, 63, 94, 0.18); }

/* --- ГРАФІК ЗМІН --- */
.avatar-shift-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-muted);
    border: 2px solid var(--bg-surface, #1a1f2e);
}
.avatar-shift-dot.on {
    background: var(--accent-emerald);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}
.shift-indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    display: inline-block;
}
.shift-indicator-dot.on {
    background: var(--accent-emerald);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}
.shift-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.shift-toggle-btn .shift-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
}
.shift-toggle-btn.on {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--accent-emerald);
}
.shift-toggle-btn.on .shift-dot {
    background: var(--accent-emerald);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}
.shift-toggle-btn:active { transform: scale(0.96); }

/* --- НАЛАШТУВАННЯ СПОВІЩЕНЬ --- */
.notif-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.notif-toggle-row:last-of-type {
    border-bottom: none;
}
.notif-toggle-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.notif-toggle-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.notif-toggle-desc {
    font-size: 11.5px;
    color: var(--text-secondary);
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 26px;
    flex-shrink: 0;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 26px;
    transition: all 0.2s ease;
}
.switch-slider::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    left: 2px;
    top: 2px;
    background: white;
    border-radius: 50%;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
.switch input:checked + .switch-slider {
    background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
    border-color: rgba(139, 92, 246, 0.4);
}
.switch input:checked + .switch-slider::before {
    transform: translateX(18px);
}

/* --- VIEW 4: PAYMENTS & FINANCE --- */
.payment-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 20px;
}
.pay-tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 10px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
}
.pay-tab-btn.active { background: var(--bg-card); color: white; border: 1px solid rgba(255, 255, 255, 0.05); }

.pay-tab-content { display: none; }
.pay-tab-content.active { display: block; }

.finance-panel h3 { font-size: 14px; font-weight: 700; font-family: 'Outfit', sans-serif; }
.finance-submit { margin-top: 10px; font-size: 13px; padding: 12px; }

.finance-section { margin-top: 24px; }
.payment-route-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.payment-route-details { display: flex; flex-direction: column; gap: 2px; }
.route-service-name { font-size: 13px; font-weight: 700; color: var(--accent-purple); }
.route-email-val { font-size: 11px; color: var(--text-secondary); }

.crypto-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-premium);
}
.crypto-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.crypto-name { font-family: 'Outfit', sans-serif; font-size: 15px; font-weight: 700; }
.crypto-badge { font-size: 9px; font-weight: 700; text-transform: uppercase; background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); padding: 2px 8px; border-radius: 10px; }
.crypto-card p { font-size: 12px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 16px; }

.address-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 12px;
}
.address-lbl { font-size: 10px; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.address-row { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.address-val { font-family: monospace; font-size: 13px; color: white; }
.copy-btn { background: transparent; border: none; font-size: 14px; cursor: pointer; padding: 4px; }

/* --- VIEW 5: AI & MOTIVATION --- */
.ai-panel h3 { font-size: 14px; font-weight: 700; font-family: 'Outfit', sans-serif; }
.ai-brain-icon { font-size: 20px; }
.ai-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.ai-submit { margin-top: 10px; font-size: 13px; padding: 12px; }

.motivation-section {
    background: radial-gradient(circle at 10% 10%, #1d123b, var(--bg-surface));
    border: 1px solid rgba(139, 92, 246, 0.18);
    box-shadow: 0 10px 25px -10px rgba(139, 92, 246, 0.15);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-top: 10px;
}
.motivation-header { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--accent-purple); margin-bottom: 12px; }
.motivation-quote { font-size: 14px; font-style: italic; color: white; line-height: 1.6; margin-bottom: 16px; }
.refresh-quote-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    padding: 8px 14px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.refresh-quote-btn:active { background: rgba(255, 255, 255, 0.05); color: white; }

/* --- BOTTOM STICKY NAVIGATION BAR --- */
.app-nav {
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    background: rgba(18, 18, 25, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 24px;
    margin: 0 15px 15px 15px;
    padding: 12px 10px;
    position: sticky;
    bottom: 15px;
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 8px 10px;
    cursor: pointer;
    transition: var(--transition);
    border-radius: 12px;
    flex: 1;
}

.nav-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.nav-label {
    font-size: 10px;
    font-weight: 500;
    transition: color 0.2s ease;
}

.nav-item.active {
    color: var(--accent-purple);
}

.nav-item.active .nav-icon {
    transform: scale(1.18) translateY(-2px);
    filter: drop-shadow(0 0 5px rgba(139, 92, 246, 0.4));
}

.nav-item.active .nav-label {
    font-weight: 700;
    color: white;
}

/* --- TOAST NOTIFICATIONS --- */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: calc(100% - 40px);
    max-width: 400px;
    pointer-events: none;
}

.toast {
    background: rgba(18, 14, 38, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: white;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-premium);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastSlideIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.removing {
    opacity: 0;
    transform: translate(-50%, -20px) scale(0.9);
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.toast-success { border-left: 3.5px solid var(--accent-emerald); }
.toast-error { border-left: 3.5px solid var(--accent-rose); }
.toast-info { border-left: 3.5px solid var(--accent-purple); }

.toast-icon { font-size: 16px; }

/* --- AUTHENTICATION VIEW STYLES --- */
.auth-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
    padding: 20px 0;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

.auth-header {
    margin-bottom: 30px;
}

.auth-icon {
    font-size: 48px;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.5));
}

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

.auth-card {
    width: 100%;
    max-width: 350px;
    padding: 24px;
    text-align: left;
}

.auth-card-title {
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.auth-card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.4;
}

.auth-owner-hint {
    margin-top: 15px;
    border-style: dashed;
    background: rgba(255, 255, 255, 0.02);
}

.auth-owner-hint .auth-card-desc {
    margin-bottom: 0;
}

.auth-owner-hint code {
    background: rgba(139, 92, 246, 0.2);
    color: var(--accent-purple);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 14px;
}

/* --- SIDE DRAWER MENU --- */
.drawer-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.drawer-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.side-drawer {
    position: fixed;
    top: 0; right: -300px;
    width: 300px;
    height: 100vh;
    background: rgba(26, 32, 44, 0.85); /* Glassmorphism background */
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px 0 0 24px; /* Soft rounded corners on the left */
    z-index: 1000;
    box-shadow: -10px 0 40px rgba(0,0,0,0.6);
    transition: right 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); /* Bouncy slide in */
    display: flex;
    flex-direction: column;
}
.side-drawer.active {
    right: 0;
}
.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 18px;
    border-bottom: 1px solid var(--border-glass);
    position: relative;
}
.drawer-header::after {
    content: "";
    position: absolute;
    left: 20px; right: 20px; bottom: -1px;
    height: 1px;
    background: linear-gradient(90deg, var(--accent-indigo), var(--accent-purple), transparent);
}
.drawer-header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}
.drawer-header-badge {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
    flex-shrink: 0;
}
.drawer-header h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 17px;
    font-weight: 700;
    margin: 0;
}
.close-drawer {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    font-size: 15px;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}
.close-drawer:hover, .close-drawer:active {
    background: rgba(244, 63, 94, 0.15);
    border-color: rgba(244, 63, 94, 0.3);
    color: var(--accent-rose);
    transform: rotate(90deg);
}
.drawer-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}
.drawer-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-glass), transparent);
    margin: 6px 4px;
}
.drawer-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 600;
    display: flex;
    flex-direction: row; /* .drawer-item поєднується з класом .nav-item (нижня панель),
                             яка задає flex-direction: column — без явного row тут
                             картка меню розтягувалась у вертикальну колонку */
    flex: 0 0 auto; /* скидаємо flex: 1 з .nav-item, інакше кожен пункт розтягується
                        на всю доступну висоту бокового меню */
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    width: 100%;
    opacity: 0;
    transform: translateX(12px);
    animation: drawerItemIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.side-drawer:not(.active) .drawer-item { animation: none; opacity: 0; }
.drawer-content .drawer-item:nth-child(1) { animation-delay: 0.04s; }
.drawer-content .drawer-item:nth-child(2) { animation-delay: 0.08s; }
.drawer-content .drawer-item:nth-child(3) { animation-delay: 0.12s; }
.drawer-content .drawer-item:nth-child(4) { animation-delay: 0.16s; }
.drawer-content .drawer-item:nth-child(5) { animation-delay: 0.2s; }
.drawer-content .drawer-item:nth-child(6) { animation-delay: 0.24s; }
.drawer-content .drawer-item:nth-child(7) { animation-delay: 0.28s; }
.drawer-content .drawer-item:nth-child(9) { animation-delay: 0.32s; }
@keyframes drawerItemIn {
    to { opacity: 1; transform: translateX(0); }
}
.drawer-icon {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    background: rgba(139, 92, 246, 0.14);
    border: 1px solid rgba(139, 92, 246, 0.18);
    transition: all 0.2s ease;
}
.drawer-item[data-accent="purple"] .drawer-icon { background: rgba(139, 92, 246, 0.14); border-color: rgba(139, 92, 246, 0.2); }
.drawer-item[data-accent="indigo"] .drawer-icon { background: rgba(99, 102, 241, 0.14); border-color: rgba(99, 102, 241, 0.2); }
.drawer-item[data-accent="emerald"] .drawer-icon { background: rgba(16, 185, 129, 0.14); border-color: rgba(16, 185, 129, 0.2); }
.drawer-item[data-accent="amber"] .drawer-icon { background: rgba(245, 158, 11, 0.14); border-color: rgba(245, 158, 11, 0.2); }
.drawer-item[data-accent="rose"] .drawer-icon { background: rgba(244, 63, 94, 0.14); border-color: rgba(244, 63, 94, 0.2); }
.drawer-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.drawer-chevron {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--text-muted);
    opacity: 0;
    transform: translateX(-4px);
    transition: all 0.2s ease;
}
.drawer-item:hover, .drawer-item:active {
    background: rgba(139, 92, 246, 0.12);
    border-color: rgba(139, 92, 246, 0.35);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.18);
}
.drawer-item:hover .drawer-icon, .drawer-item:active .drawer-icon {
    transform: scale(1.08);
}
.drawer-item:hover .drawer-chevron, .drawer-item:active .drawer-chevron {
    opacity: 1;
    transform: translateX(0);
    color: var(--accent-purple);
}
.client-help-text {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
    white-space: pre-wrap;
}

/* --- СПОВІЩЕННЯ ПРО ПРОСТРОЧЕНІ ЗАДАЧІ --- */
.overdue-notice-sheet {
    z-index: 1100; /* понад звичайні sheet'и, це критичне сповіщення при вході */
}
.overdue-notice-body {
    padding: 8px 24px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
}
.overdue-notice-icon {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    background: linear-gradient(135deg, rgba(244, 63, 94, 0.25), rgba(245, 158, 11, 0.25));
    border: 1px solid rgba(244, 63, 94, 0.3);
    box-shadow: 0 4px 20px rgba(244, 63, 94, 0.25);
    margin-bottom: 6px;
    animation: overdueIconPulse 1.8s ease-in-out infinite;
}
@keyframes overdueIconPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}
.overdue-notice-title {
    font-family: 'Outfit', sans-serif;
    font-size: 19px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}
.overdue-notice-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0 0 14px;
}
.overdue-notice-text span {
    color: var(--accent-rose);
    font-weight: 700;
}
.overdue-notice-body .submit-btn {
    background: linear-gradient(135deg, var(--accent-rose), var(--accent-amber));
    box-shadow: 0 4px 15px rgba(244, 63, 94, 0.25);
}
.overdue-notice-dismiss {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    padding: 12px;
    cursor: pointer;
    width: 100%;
}
.overdue-notice-dismiss:active { color: var(--text-primary); }

/* --- СВІТЛА ТЕМА: DRAWER --- */
body.tg-light .side-drawer {
    background: rgba(255, 255, 255, 0.97);
    border-left: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.12);
}

body.tg-light .drawer-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

body.tg-light .drawer-header h3 {
    color: #111827;
}

body.tg-light .drawer-header::after {
    background: linear-gradient(90deg, var(--accent-indigo), var(--accent-purple), transparent);
}

body.tg-light .close-drawer {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #111827;
}

body.tg-light .drawer-item {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.07);
    color: #111827;
}

body.tg-light .drawer-item:hover,
body.tg-light .drawer-item:active {
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.3);
    color: #111827;
}

body.tg-light .drawer-overlay {
    background: rgba(0, 0, 0, 0.3);
}
/* ================================================
   СВІТЛА ТЕМА — ПОВНИЙ ФІКС ВСІХ ЕЛЕМЕНТІВ
   ================================================ */

/* Bottom Navigation */
body.tg-light .app-nav {
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
}

body.tg-light .nav-item {
    color: #6B7280;
}

body.tg-light .nav-item.active {
    color: #8B5CF6;
}

body.tg-light .nav-item.active .nav-label {
    color: #8B5CF6;
    font-weight: 700;
}

/* Task Cards */
body.tg-light .task-card {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

body.tg-light .task-footer-info {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    color: #6B7280;
}

body.tg-light .task-desc-content {
    color: #111827;
}

/* Task Control Buttons */
body.tg-light .task-ctrl-btn {
    border: 1px solid rgba(0, 0, 0, 0.1);
}

body.tg-light .btn-ctrl-progress {
    background: rgba(139, 92, 246, 0.08);
    color: #7C3AED;
    border-color: rgba(139, 92, 246, 0.2);
}

body.tg-light .btn-ctrl-complete {
    background: rgba(16, 185, 129, 0.08);
    color: #059669;
    border-color: rgba(16, 185, 129, 0.2);
}

body.tg-light .btn-ctrl-stop {
    background: rgba(244, 63, 94, 0.06);
    color: #E11D48;
    border-color: rgba(244, 63, 94, 0.15);
}

body.tg-light .btn-ctrl-delete {
    background: rgba(0, 0, 0, 0.04);
    color: #6B7280;
    border-color: rgba(0, 0, 0, 0.1);
}

body.tg-light .btn-ctrl-delete:active {
    background: rgba(244, 63, 94, 0.1);
    color: #E11D48;
    border-color: rgba(244, 63, 94, 0.2);
}

/* Priority Badges */
body.tg-light .task-card.completed .task-meta-badge {
    background: rgba(0, 0, 0, 0.06);
    color: #9CA3AF;
}

/* Stats Cards */
body.tg-light .stat-card {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

body.tg-light .stat-value {
    color: #111827;
}

body.tg-light .stat-label {
    color: #6B7280;
}

/* Search Bar */
body.tg-light .search-bar {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

body.tg-light .search-bar input {
    color: #111827;
}

/* Tab Buttons */
body.tg-light .task-tab-btn {
    background: rgba(0, 0, 0, 0.05);
    color: #4B5563;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

body.tg-light .task-tab-btn.active {
    background: white;
    color: #111827;
    border-color: rgba(0, 0, 0, 0.12);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* View Titles */
body.tg-light .view-title {
    color: #111827;
}

/* Form Elements */
body.tg-light .form-input,
body.tg-light .form-select,
body.tg-light textarea {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #111827;
}

body.tg-light .form-input::placeholder,
body.tg-light textarea::placeholder {
    color: #9CA3AF;
}

body.tg-light .form-label {
    color: #374151;
}

/* Staff Cards */
body.tg-light .staff-member-card {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

body.tg-light .staff-name {
    color: #111827;
}

/* Section Headers */
body.tg-light .section-header {
    color: #374151;
}

/* Toast (залишаємо як є — вони мають власні кольори) */
/* --- ACTION SHEET (BOTTOM SHEET) --- */
.action-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--bg-surface);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    z-index: 1000;
    /* 🛡️ transform замість "bottom: -100%" — bottom як відсоток
       рахується від висоти containing block (в Telegram WebView в
       компактному, нерозгорнутому режимі вона може відрізнятись від
       того, що реально видно), через що шторка інколи лишалась видимою
       знизу навіть у "закритому" стані. translateY(100%) рахується від
       ВЛАСНОЇ висоти елемента — завжди коректно виштовхує його за межі
       екрана, незалежно від вьюпорту. */
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding-bottom: env(safe-area-inset-bottom, 20px);
    border-top: 1px solid var(--border-glass);
    pointer-events: none;
}
.action-sheet.active {
    transform: translateY(0);
    pointer-events: auto;
}

/* Шторки другого рівня — ті, що відкриваються ПОВЕРХ уже відкритої
   картки моделі (платіж, крипто, мости та їх редагування). Базовий
   z-index (999/1000) однаковий для всіх шторок, тому без цього рівня
   новий оверлей не міг перекрити вже відкриту картку моделі — обидві
   шторки опинялись на одному "поверсі", і було видно нижній край
   першої разом із заголовком другої. */
#model-payment-form-overlay, #model-crypto-form-overlay,
#bridge-form-overlay, #edit-crypto-wallet-overlay,
#edit-payment-route-overlay, #edit-bridge-overlay,
#orphaned-routes-overlay {
    z-index: 1099;
}
#model-payment-form-sheet, #model-crypto-form-sheet,
#bridge-form-sheet, #edit-crypto-wallet-sheet,
#edit-payment-route-sheet, #edit-bridge-sheet,
#orphaned-routes-sheet {
    z-index: 1100;
}

.sheet-indicator {
    width: 40px;
    height: 5px;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    margin: 12px auto;
}
.sheet-header {
    padding: 5px 20px 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.sheet-header-title {
    margin: 0;
    font-size: 18px;
}
.sheet-content {
    padding: 10px 20px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sheet-item {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-glass);
    padding: 14px;
    border-radius: 16px;
    color: white;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.sheet-item:active {
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.3);
    transform: translateY(-1px);
}
.sheet-icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    background: rgba(139, 92, 246, 0.14);
    border: 1px solid rgba(139, 92, 246, 0.2);
    transition: transform 0.2s ease;
}
.sheet-item[data-accent="purple"] .sheet-icon { background: rgba(139, 92, 246, 0.14); border-color: rgba(139, 92, 246, 0.2); }
.sheet-item[data-accent="emerald"] .sheet-icon { background: rgba(16, 185, 129, 0.14); border-color: rgba(16, 185, 129, 0.2); }
.sheet-item:active .sheet-icon { transform: scale(1.06); }
.sheet-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.sheet-text strong {
    font-size: 16px;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
}
.sheet-text span {
    font-size: 13px;
    color: var(--text-secondary);
}
.sheet-chevron {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--text-muted);
}

/* --- ROLE MANAGEMENT --- */
.role-badge {
    font-size: 10px;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.role-owner { background: rgba(255, 215, 0, 0.15); color: #ffd700; border: 1px solid rgba(255, 215, 0, 0.3); }
.role-head { background: rgba(255, 87, 34, 0.15); color: #ff5722; border: 1px solid rgba(255, 87, 34, 0.3); }
.role-team { background: rgba(139, 92, 246, 0.15); color: #a78bfa; border: 1px solid rgba(139, 92, 246, 0.3); }
.role-manager { background: rgba(33, 150, 243, 0.15); color: #60a5fa; border: 1px solid rgba(33, 150, 243, 0.3); }
.role-trainee { background: rgba(76, 175, 80, 0.15); color: #81c784; border: 1px solid rgba(76, 175, 80, 0.3); }

.btn-change-role {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.07);
    font-size: 11px;
    cursor: pointer;
    width: 22px;
    height: 22px;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.75;
    transition: opacity 0.2s, transform 0.2s, background 0.2s;
}
.btn-change-role:hover, .btn-change-role:active {
    opacity: 1;
    transform: scale(1.08);
    background: rgba(139, 92, 246, 0.15);
}

.role-dropdown-menu {
    position: fixed;
    background: rgba(26, 32, 44, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 6px;
    z-index: 10000;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.role-menu-item {
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}
.role-menu-item:hover {
    background: rgba(139, 92, 246, 0.2);
}
.role-menu-item.active {
    background: rgba(139, 92, 246, 0.4);
    color: #fff;
}
/* Фікс відступу для нижнього меню */
.app-content {
    padding-bottom: 140px !important;
}

/* Стилі для розкривного списку референсів */
.custom-details summary {
    list-style: none;
    cursor: pointer;
}
.custom-details summary::-webkit-details-marker {
    display: none;
}
.ref-scroll-container {
    max-height: 350px;
    overflow-y: auto;
    padding-right: 5px;
}