/* =========================================================================
   UNEAK CRM — единый самодостаточный стилевой файл.
   Все стили, необходимые для отображения CRM, находятся здесь.
   Файл tailwind.css подключается как дополнительный (там базовые утилиты),
   но app.css не зависит от него.
   ========================================================================= */

/* ----------------------------------------------------------------------- */
/*  CSS Custom Properties (Brand Palette)                                  */
/* ----------------------------------------------------------------------- */
:root {
    /* Primary brand colours (extracted from the UNEAK logo). */
    --primary-green: #1e3a3a;
    --primary-blue: #7dd3fc;
    --primary-blue-dark: #0891b2;
    --primary-blue-light: #bae6fd;

    /* Accent palette. */
    --accent-teal: #14b8a6;
    --accent-teal-light: #5eead4;
    --sage-green: #86efac;
    --sage-green-dark: #22c55e;

    /* Neutrals. */
    --neutral-50: #f8fafc;
    --neutral-100: #f1f5f9;
    --neutral-200: #e2e8f0;
    --neutral-300: #cbd5e1;
    --neutral-400: #94a3b8;
    --neutral-500: #64748b;
    --neutral-600: #475569;
    --neutral-700: #334155;
    --neutral-800: #1e293b;
    --neutral-900: #0f172a;

    /* Semantic colours. */
    --color-success: #16a34a;
    --color-warning: #ca8a04;
    --color-error: #dc2626;
    --color-info: #2563eb;
}

/* ----------------------------------------------------------------------- */
/*  Base / Reset                                                           */
/* ----------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { scroll-behavior: smooth; height: 100%; }
body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--neutral-50);
    color: var(--neutral-800);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
input, button, textarea, select { font: inherit; color: inherit; }
ul, ol { list-style: none; }

/* ----------------------------------------------------------------------- */
/*  Display & Layout Helpers                                               */
/* ----------------------------------------------------------------------- */
.hidden { display: none !important; }
.block { display: block; }
.inline { display: inline; }
.inline-block { display: inline-block; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.table { display: table; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1 1 0%; }
.flex-shrink-0 { flex-shrink: 0; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.space-x-2 > * + * { margin-left: 0.5rem; }
.space-x-3 > * + * { margin-left: 0.75rem; }
.space-x-4 > * + * { margin-left: 1rem; }
.space-y-1 > * + * { margin-top: 0.25rem; }
.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.space-y-6 > * + * { margin-top: 1.5rem; }
.divide-y > * + * { border-top: 1px solid var(--neutral-200); }

/* Container */
.container { width: 100%; margin-left: auto; margin-right: auto; padding-left: 1rem; padding-right: 1rem; }
.max-w-7xl { max-width: 80rem; }
.max-w-6xl { max-width: 72rem; }
.max-w-5xl { max-width: 64rem; }
.max-w-4xl { max-width: 56rem; }
.max-w-3xl { max-width: 48rem; }
.max-w-2xl { max-width: 42rem; }
.max-w-xl { max-width: 36rem; }
.max-w-lg { max-width: 32rem; }
.max-w-md { max-width: 28rem; }
.max-w-sm { max-width: 24rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

/* Width / Height */
.w-full { width: 100%; }
.w-auto { width: auto; }
.w-4 { width: 1rem; }
.w-5 { width: 1.25rem; }
.w-6 { width: 1.5rem; }
.w-7 { width: 1.75rem; }
.w-8 { width: 2rem; }
.w-10 { width: 2.5rem; }
.w-12 { width: 3rem; }
.w-16 { width: 4rem; }
.w-20 { width: 5rem; }
.w-24 { width: 6rem; }
.h-4 { height: 1rem; }
.h-5 { height: 1.25rem; }
.h-6 { height: 1.5rem; }
.h-7 { height: 1.75rem; }
.h-8 { height: 2rem; }
.h-10 { height: 2.5rem; }
.h-12 { height: 3rem; }
.h-16 { height: 4rem; }
.h-20 { height: 5rem; }
.h-24 { height: 6rem; }
.min-h-screen { min-height: 100vh; }

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

/* ----------------------------------------------------------------------- */
/*  Spacing                                                                 */
/* ----------------------------------------------------------------------- */
.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.py-10 { padding-top: 2.5rem; padding-bottom: 2.5rem; }
.py-12 { padding-top: 3rem; padding-bottom: 3rem; }
.pt-3 { padding-top: 0.75rem; }
.pt-4 { padding-top: 1rem; }
.pt-6 { padding-top: 1.5rem; }
.pb-3 { padding-bottom: 0.75rem; }
.pb-6 { padding-bottom: 1.5rem; }
.m-0 { margin: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mt-12 { margin-top: 3rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.ml-1 { margin-left: 0.25rem; }
.ml-2 { margin-left: 0.5rem; }
.ml-3 { margin-left: 0.75rem; }
.ml-4 { margin-left: 1rem; }
.ml-5 { margin-left: 1.25rem; }
.mr-1 { margin-right: 0.25rem; }
.mr-2 { margin-right: 0.5rem; }
.mr-3 { margin-right: 0.75rem; }

/* ----------------------------------------------------------------------- */
/*  Typography                                                              */
/* ----------------------------------------------------------------------- */
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }
.uppercase { text-transform: uppercase; }
.capitalize { text-transform: capitalize; }
.tracking-wide { letter-spacing: 0.025em; }
.tracking-wider { letter-spacing: 0.05em; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.leading-tight { line-height: 1.25; }
.leading-relaxed { line-height: 1.625; }
.whitespace-pre-line { white-space: pre-line; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.list-disc { list-style-type: disc; }
.list-inside { list-style-position: inside; }

/* Text colours */
.text-white { color: #fff; }
.text-black { color: #000; }
.text-current { color: currentColor; }
.text-gray-400 { color: var(--neutral-400); }
.text-gray-500 { color: var(--neutral-500); }
.text-gray-600 { color: var(--neutral-600); }
.text-gray-700 { color: var(--neutral-700); }
.text-gray-800 { color: var(--neutral-800); }
.text-gray-900 { color: var(--neutral-900); }
.text-red-500 { color: #ef4444; }
.text-red-600 { color: #dc2626; }
.text-red-700 { color: #b91c1c; }
.text-green-600 { color: #16a34a; }
.text-green-700 { color: #15803d; }
.text-green-800 { color: #166534; }
.text-blue-600 { color: #2563eb; }
.text-blue-700 { color: #1d4ed8; }
.text-blue-800 { color: #1e40af; }
.text-teal-600 { color: #0d9488; }
.text-teal-700 { color: #0f766e; }
.text-teal-800 { color: #115e59; }
.text-yellow-600 { color: #ca8a04; }
.text-yellow-800 { color: #854d0e; }
.text-purple-700 { color: #7e22ce; }
.text-purple-800 { color: #6b21a8; }

/* Background colours */
.bg-white { background-color: #fff; }
.bg-transparent { background-color: transparent; }
.bg-gray-50 { background-color: var(--neutral-50); }
.bg-gray-100 { background-color: var(--neutral-100); }
.bg-gray-200 { background-color: var(--neutral-200); }
.bg-gray-600 { background-color: #4b5563; }
.bg-green-50 { background-color: #f0fdf4; }
.bg-green-100 { background-color: #dcfce7; }
.bg-green-600 { background-color: #16a34a; }
.bg-blue-50 { background-color: #eff6ff; }
.bg-blue-100 { background-color: #dbeafe; }
.bg-blue-600 { background-color: #2563eb; }
.bg-red-50 { background-color: #fef2f2; }
.bg-red-100 { background-color: #fee2e2; }
.bg-red-500 { background-color: #ef4444; }
.bg-red-600 { background-color: #dc2626; }
.bg-teal-50 { background-color: #f0fdfa; }
.bg-teal-100 { background-color: #ccfbf1; }
.bg-purple-50 { background-color: #faf5ff; }
.bg-purple-100 { background-color: #f3e8ff; }
.bg-yellow-50 { background-color: #fefce8; }
.bg-yellow-100 { background-color: #fef9c3; }
.bg-yellow-500 { background-color: #eab308; }

/* ----------------------------------------------------------------------- */
/*  Borders & Rounded Corners                                              */
/* ----------------------------------------------------------------------- */
.border { border: 1px solid var(--neutral-200); }
.border-0 { border: none; }
.border-t { border-top: 1px solid var(--neutral-200); }
.border-b { border-bottom: 1px solid var(--neutral-200); }
.border-l-4 { border-left-width: 4px; border-left-style: solid; }
.border-l-4.border-green-500 { border-left-color: #22c55e; }
.border-l-4.border-yellow-500 { border-left-color: #eab308; }
.border-l-4.border-blue-500 { border-left-color: #3b82f6; }
.border-l-4.border-red-500 { border-left-color: #ef4444; }
.border-l-4.border-gray-500 { border-left-color: #6b7280; }
.border-white\/10 { border-color: rgba(255, 255, 255, 0.1); }
.border-white\/20 { border-color: rgba(255, 255, 255, 0.2); }
.border-gray-100 { border-color: var(--neutral-100); }
.border-gray-200 { border-color: var(--neutral-200); }
.border-gray-300 { border-color: var(--neutral-300); }
.border-green-200 { border-color: #bbf7d0; }
.border-green-400 { border-color: #4ade80; }
.border-red-200 { border-color: #fecaca; }
.border-red-400 { border-color: #f87171; }
.border-blue-200 { border-color: #93c5fd; }
.border-blue-400 { border-color: #60a5fa; }
.border-yellow-200 { border-color: #fde68a; }
.border-yellow-400 { border-color: #facc15; }
.rounded { border-radius: 0.25rem; }
.rounded-sm { border-radius: 0.125rem; }
.rounded-md { border-radius: 0.375rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-xl { border-radius: 0.75rem; }
.rounded-2xl { border-radius: 1rem; }
.rounded-full { border-radius: 9999px; }
.rounded-t-md { border-top-left-radius: 0.375rem; border-top-right-radius: 0.375rem; }
.rounded-b-md { border-bottom-left-radius: 0.375rem; border-bottom-right-radius: 0.375rem; }

/* ----------------------------------------------------------------------- */
/*  Shadows                                                                */
/* ----------------------------------------------------------------------- */
.shadow-sm { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
.shadow { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06); }
.shadow-md { box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06); }
.shadow-lg { box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05); }
.shadow-xl { box-shadow: 0 20px 25px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.04); }

/* ----------------------------------------------------------------------- */
/*  Buttons                                                                */
/* ----------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.15s ease;
    cursor: pointer;
    border: 1px solid transparent;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent-teal); color: #fff; border-color: var(--accent-teal); }
.btn-primary:hover { background: #0f9e8f; border-color: #0f9e8f; }
.btn-secondary { background: #fff; color: var(--neutral-700); border-color: var(--neutral-300); }
.btn-secondary:hover { background: var(--neutral-100); }
.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-ghost { background: transparent; color: var(--neutral-700); border-color: transparent; }
.btn-ghost:hover { background: var(--neutral-100); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.75rem; }
.btn-xs { padding: 0.2rem 0.4rem; font-size: 0.65rem; }

/* ----------------------------------------------------------------------- */
/*  Forms                                                                  */
/* ----------------------------------------------------------------------- */
.form-label { display: block; font-weight: 500; color: var(--neutral-700); margin-bottom: 0.25rem; }
.form-input,
.form-select,
.form-textarea {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--neutral-300);
    border-radius: 0.5rem;
    background: #fff;
    color: var(--neutral-900);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    font-size: 0.875rem;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-teal);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.18);
}
.form-input::placeholder { color: var(--neutral-400); }
.form-help { font-size: 0.8rem; color: var(--neutral-500); margin-top: 0.25rem; }
.form-error { font-size: 0.8rem; color: #dc2626; }

/* ----------------------------------------------------------------------- */
/*  Brand Colour Utilities                                                 */
/* ----------------------------------------------------------------------- */
.bg-brand-primary { background-color: var(--primary-green); }
.bg-brand-secondary { background-color: var(--primary-blue); }
.bg-brand-accent { background-color: var(--accent-teal); }
.text-brand-primary { color: var(--primary-green); }
.text-brand-secondary { color: var(--primary-blue-dark); }
.text-brand-accent { color: var(--accent-teal); }
.border-brand-primary { border-color: var(--primary-green); }
.border-brand-secondary { border-color: var(--primary-blue); }
.border-brand-accent { border-color: var(--accent-teal); }
.hover\:bg-brand-primary:hover { background-color: var(--primary-green); }
.hover\:bg-brand-accent:hover { background-color: var(--accent-teal); }
.hover\:text-brand-primary:hover { color: var(--primary-green); }

/* Status-specific coloured text (for badges based on status_badge_class) */
.text-status-active,
.text-status-open,
.text-status-planned,
.text-status-confirmed { color: #166534; }
.text-status-in_progress,
.text-status-pending,
.text-status-review { color: #1e40af; }
.text-status-done,
.text-status-completed,
.text-status-implemented { color: #115e59; }
.text-status-cancelled,
.text-status-rejected,
.text-status-failed { color: #991b1b; }
.text-status-paused,
.text-status-suspended,
.text-status-on_hold { color: var(--neutral-700); }

.bg-status-active,
.bg-status-open,
.bg-status-planned,
.bg-status-confirmed { background-color: #dcfce7; }
.bg-status-in_progress,
.bg-status-pending,
.bg-status-review { background-color: #dbeafe; }
.bg-status-done,
.bg-status-completed,
.bg-status-implemented { background-color: #ccfbf1; }
.bg-status-cancelled,
.bg-status-rejected,
.bg-status-failed { background-color: #fee2e2; }
.bg-status-paused,
.bg-status-suspended,
.bg-status-on_hold { background-color: var(--neutral-100); }

/* ----------------------------------------------------------------------- */
/*  Header                                                                 */
/* ----------------------------------------------------------------------- */
.app-header {
    background: linear-gradient(135deg, var(--primary-green) 0%, #123b37 100%);
    border-bottom: 3px solid var(--accent-teal);
    color: #fff;
}
/* Header nav links only (not dropdown/admin links) */
.app-header .nav-link,
.app-header a.nav-link {
    color: rgba(255, 255, 255, 0.9);
    transition: all 0.2s ease;
    border-radius: 6px;
}
.app-header .nav-link:hover,
.app-header a.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}
.app-header .nav-link-active {
    background-color: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-weight: 600;
}

/* ----------------------------------------------------------------------- */
/*  Cards & Widgets                                                        */
/* ----------------------------------------------------------------------- */
.widget-card {
    background: #fff;
    border: 1px solid var(--neutral-200);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
}
.widget-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.card-grid {
    display: grid;
    gap: 1.5rem;
}

/* Clickable items */
.clickable-item {
    cursor: pointer;
    transition: all 0.2s ease;
}
.clickable-item:hover {
    background-color: var(--primary-blue-light);
    transform: translateY(-1px);
}

/* Section headers (collapsible accordion) */
.section-header {
    cursor: pointer;
    transition: all 0.2s ease;
}
.section-header:hover {
    background-color: var(--primary-blue-light);
}
.section-icon {
    transition: transform 0.2s ease;
}
.section-collapsed .section-icon {
    transform: rotate(-90deg);
}

/* ----------------------------------------------------------------------- */
/*  Hero / KPI Panel (Dashboard)                                           */
/* ----------------------------------------------------------------------- */
.hero-analytics {
    border-radius: 1rem;
    background: linear-gradient(135deg, var(--primary-blue-dark) 0%, var(--accent-teal) 50%, var(--sage-green-dark) 100%);
    color: #fff;
}
.kpi-card {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    backdrop-filter: blur(4px);
}
.kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
}
.kpi-label {
    font-size: 0.75rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Stats grid */
.stats-grid {
    display: grid;
    gap: 1rem;
}

/* ----------------------------------------------------------------------- */
/*  Status Badges                                                           */
/* ----------------------------------------------------------------------- */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 999px;
    white-space: nowrap;
    border: 1px solid transparent;
}

/* Individual status colours */
.status-implemented { background-color: var(--sage-green); color: var(--primary-green); border-color: var(--sage-green-dark); }
.status-discussion  { background-color: var(--primary-blue-light); color: var(--primary-blue-dark); border-color: var(--primary-blue); }
.status-agreement   { background-color: var(--accent-teal-light); color: var(--primary-green); border-color: var(--accent-teal); }
.status-paused      { background-color: var(--neutral-100); color: var(--neutral-700); border-color: var(--neutral-200); }

/* Task priorities */
.priority-urgent  { background-color: #fecaca; color: #b91c1c; border-color: #f87171; }
.priority-high    { background-color: #fed7aa; color: #c2410c; border-color: #fb923c; }
.priority-medium  { background-color: var(--primary-blue-light); color: var(--primary-blue-dark); border-color: var(--primary-blue); }
.priority-low     { background-color: var(--neutral-100); color: var(--neutral-700); border-color: var(--neutral-200); }

/* Task statuses */
.status-new        { background-color: var(--primary-blue-light); color: var(--primary-blue-dark); border-color: var(--primary-blue); }
.status-in-progress { background-color: var(--accent-teal-light); color: var(--primary-green); border-color: var(--accent-teal); }
.status-completed  { background-color: var(--sage-green); color: var(--primary-green); border-color: var(--sage-green-dark); }

/* ----------------------------------------------------------------------- */
/*  Progress Bars                                                           */
/* ----------------------------------------------------------------------- */
.progress-bar {
    background-color: var(--neutral-200);
    border-radius: 9999px;
    height: 0.5rem;
    overflow: hidden;
}
.progress-fill {
    background: linear-gradient(90deg, var(--accent-teal), var(--primary-blue-dark));
    height: 100%;
    transition: width 0.5s ease;
}

/* ----------------------------------------------------------------------- */
/*  Loading Spinner                                                        */
/* ----------------------------------------------------------------------- */
.loading-spinner {
    border: 2px solid transparent;
    border-top: 2px solid var(--accent-teal);
    border-radius: 50%;
    width: 1rem;
    height: 1rem;
    animation: spin 1s linear infinite;
    display: inline-block;
}
@keyframes spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ----------------------------------------------------------------------- */
/*  Flash Messages                                                         */
/* ----------------------------------------------------------------------- */
.flash {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid transparent;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.flash-success { background: #dcfce7; border-color: #86efac; color: #166534; }
.flash-error   { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.flash-warning { background: #fef9c3; border-color: #fde047; color: #854d0e; }
.flash-info    { background: #dbeafe; border-color: #93c5fd; color: #1e40af; }

/* ----------------------------------------------------------------------- */
/*  Notifications / Toasts (animated)                                      */
/* ----------------------------------------------------------------------- */
.notification {
    animation: slideInFromTop 0.3s ease-out;
}
@keyframes slideInFromTop {
    from { transform: translateY(-100px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

/* ----------------------------------------------------------------------- */
/*  Modal Dialogs                                                          */
/* ----------------------------------------------------------------------- */
.modal {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: 50;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease-out;
}
.modal.show,
.modal.open { display: flex; }
.modal-content {
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    max-width: 90vw;
    width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideInFromCenter 0.25s ease-out;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--neutral-100);
}
.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}
.modal-body { padding: 1.5rem; }
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--neutral-100);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes slideInFromCenter {
    from { transform: scale(0.95); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

/* Native <dialog> styling */
dialog {
    border: none;
    border-radius: 0.75rem;
    padding: 0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    max-width: 90vw;
    width: 560px;
}
dialog::backdrop {
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
}

/* Modal close button */
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--neutral-400);
    padding: 0.25rem;
    line-height: 1;
}
.modal-close:hover { color: var(--neutral-700); }

/* ----------------------------------------------------------------------- */
/*  Footer                                                                 */
/* ----------------------------------------------------------------------- */
.app-footer {
    background: #102a27;
    color: rgba(255, 255, 255, 0.9);
}

/* ----------------------------------------------------------------------- */
/*  Empty State                                                            */
/* ----------------------------------------------------------------------- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--neutral-500);
}
.empty-state svg {
    margin: 0 auto 1rem;
    opacity: 0.4;
}
.empty-state h3 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}
.empty-state p {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

/* ----------------------------------------------------------------------- */
/*  Table                                                                  */
/* ----------------------------------------------------------------------- */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
table.w-full {
    width: 100%;
    border-collapse: collapse;
}
.table-header {
    background-color: var(--neutral-50);
    color: var(--neutral-500);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.table-header th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 500;
}
table tbody tr {
    border-bottom: 1px solid var(--neutral-100);
    transition: background-color 0.15s ease;
}
table tbody tr:hover {
    background-color: var(--neutral-50);
}
table tbody td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
}
.table-link {
    color: var(--accent-teal);
    font-weight: 500;
}
.table-link:hover { text-decoration: underline; }

/* ----------------------------------------------------------------------- */
/*  Pagination                                                             */
/* ----------------------------------------------------------------------- */
.pagination {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
    padding: 1rem 0;
}
.pagination a,
.pagination span {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--neutral-200);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: var(--neutral-700);
    transition: all 0.15s ease;
}
.pagination a:hover {
    background: var(--accent-teal);
    color: #fff;
    border-color: var(--accent-teal);
}
.pagination .active {
    background: var(--accent-teal);
    color: #fff;
    border-color: var(--accent-teal);
}

/* ----------------------------------------------------------------------- */
/*  Breadcrumbs                                                            */
/* ----------------------------------------------------------------------- */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--neutral-500);
}
.breadcrumb a:hover { color: var(--accent-teal); text-decoration: underline; }
.breadcrumb .current { color: var(--neutral-700); font-weight: 500; }
.breadcrumb-sep { color: var(--neutral-300); }

/* ----------------------------------------------------------------------- */
/*  Misc Utilities                                                         */
/* ----------------------------------------------------------------------- */
.cursor-pointer { cursor: pointer; }
.cursor-default { cursor: default; }
.no-underline { text-decoration: none; }
.hover\:underline:hover { text-decoration: underline; }
.hover\:opacity-100:hover { opacity: 1; }
.opacity-0 { opacity: 0; }
.opacity-40 { opacity: 0.4; }
.opacity-50 { opacity: 0.5; }
.opacity-60 { opacity: 0.6; }
.opacity-70 { opacity: 0.7; }
.opacity-75 { opacity: 0.75; }
.opacity-80 { opacity: 0.8; }
.opacity-90 { opacity: 0.9; }
.pointer-events-none { pointer-events: none; }
.pointer-events-auto { pointer-events: auto; }
.object-cover { object-fit: cover; }
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.top-0 { top: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }
.z-10 { z-index: 10; }
.z-30 { z-index: 30; }
.z-40 { z-index: 40; }
.z-50 { z-index: 50; }
.z-60 { z-index: 60; }
.z-9999 { z-index: 9999; }

/* Transitions */
.transition-colors { transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease; }
.transition-all { transition: all 0.15s ease; }
.transition-shadow { transition: box-shadow 0.2s ease; }
.transition-opacity { transition: opacity 0.3s ease; }
.transition-transform { transition: transform 0.3s ease; }
.font-mono { font-family: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace; }

/* No-scrollbar */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* Focus-visible for accessibility */
.focus-visible:focus {
    outline: 2px solid var(--accent-teal);
    outline-offset: 2px;
}

/* ----------------------------------------------------------------------- */
/*  Hamburger Button (Mobile Menu)                                         */
/* ----------------------------------------------------------------------- */
.hamburger {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 24px;
    height: 24px;
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 0;
}
.hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: white;
    transition: all 0.3s ease;
    border-radius: 1px;
}
.hamburger.open span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}
.hamburger.open span:nth-child(2) {
    opacity: 0;
}
.hamburger.open span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* ----------------------------------------------------------------------- */
/*  Mobile Off-Canvas Menu                                                 */
/* ----------------------------------------------------------------------- */
.mobile-menu {
    position: fixed;
    top: 0;
    left: -100%;
    width: 80%;
    max-width: 320px;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary-green) 0%, #123b37 100%);
    z-index: 60;
    transition: left 0.3s ease;
    overflow-y: auto;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
}
.mobile-menu.open { left: 0; }

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 55;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}
.mobile-menu-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* Hide mobile elements on desktop */
@media (min-width: 768px) {
    .mobile-menu,
    .mobile-menu-overlay { display: none !important; }
}

/* ----------------------------------------------------------------------- */
/*  User Dropdown                                                          */
/* ----------------------------------------------------------------------- */
.user-dropdown {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 0.5rem;
    width: 14rem;
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--neutral-200);
    z-index: 30;
    display: none;
    /* No overflow: hidden — border-radius clips shadow nicely */
    color: var(--neutral-700);
}
.user-dropdown.open { display: block; }
.user-dropdown-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--neutral-100);
    color: var(--neutral-700);
}
.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    font-size: 0.8rem;
    color: var(--neutral-700) !important;
    transition: background-color 0.1s ease;
    text-decoration: none;
    background: transparent;
    line-height: 1.3;
}
.user-dropdown-item:hover {
    background-color: var(--neutral-50);
    color: var(--neutral-700) !important;
}
.user-dropdown-item svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    color: var(--neutral-400);
}
.user-dropdown-item:hover svg {
    color: var(--neutral-500);
}
.user-dropdown-divider {
    border-top: 1px solid var(--neutral-100);
    margin: 0.25rem 0;
}
.user-dropdown-label {
    padding: 0.25rem 1rem 0.15rem;
    font-size: 0.7rem;
    color: var(--neutral-400);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ----------------------------------------------------------------------- */
/*  Responsive Helpers                                                     */
/* ----------------------------------------------------------------------- */
@media (max-width: 640px) {
    .hidden-mobile { display: none !important; }
    .container { padding-left: 1rem; padding-right: 1rem; }
}
@media (min-width: 641px) {
    .hidden-desktop { display: none !important; }
}
@media (max-width: 767px) {
    .hidden-mobile-only { display: none !important; }
}
@media (min-width: 768px) {
    .md\:hidden { display: none !important; }
    .md\:flex { display: flex; }
    .md\:block { display: block; }
    .md\:inline { display: inline; }
    .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .md\:grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
    .lg\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .lg\:col-span-2 { grid-column: span 2 / span 2; }
}
@media (min-width: 640px) {
    .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sm\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .sm\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .sm\:col-span-2 { grid-column: span 2 / span 2; }
    .sm\:inline { display: inline; }
    .sm\:flex-row { flex-direction: row; }
    .sm\:flex { display: flex; }
}

/* ----------------------------------------------------------------------- */
/*  Opacity modifier classes (replaces Tailwind's /{opacity} syntax)       */
/* ----------------------------------------------------------------------- */
.bg-white\/10 { background-color: rgba(255, 255, 255, 0.1); }
.bg-white\/20 { background-color: rgba(255, 255, 255, 0.2); }
.bg-white\/30 { background-color: rgba(255, 255, 255, 0.3); }
.bg-black\/10 { background-color: rgba(0, 0, 0, 0.1); }
.bg-black\/20 { background-color: rgba(0, 0, 0, 0.2); }
.bg-black\/30 { background-color: rgba(0, 0, 0, 0.3); }
.border-white\/10 { border-color: rgba(255, 255, 255, 0.1); }
.border-white\/20 { border-color: rgba(255, 255, 255, 0.2); }
.hover\:bg-white\/10:hover { background-color: rgba(255, 255, 255, 0.1); }
.hover\:bg-white\/20:hover { background-color: rgba(255, 255, 255, 0.2); }
.hover\:bg-red-500\/20:hover { background-color: rgba(239, 68, 68, 0.2); }
.text-red-300 { color: #fca5a5; }

/* Touch-friendly minimum target size */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .clickable-item,
    .section-header {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }
    .clickable-item:hover,
    .section-header:hover {
        background-color: transparent;
        transform: none;
    }
    .clickable-item:active,
    .section-header:active {
        background-color: var(--primary-blue-light);
        transform: scale(0.98);
    }
}

/* ----------------------------------------------------------------------- */
/*  Dark Theme                                                             */
/* ----------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
    :root {
        --neutral-50: #0f172a;
        --neutral-100: #1e293b;
        --neutral-200: #334155;
    }
    body {
        background-color: var(--neutral-50);
        color: #e2e8f0;
    }
    .widget-card {
        background-color: var(--neutral-100);
        border-color: var(--neutral-200);
    }
    .widget-card:hover {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    }
    .modal-content { background: var(--neutral-100); }
    .user-dropdown { background: var(--neutral-100); border-color: var(--neutral-200); }
    .user-dropdown-item { color: #e2e8f0; }
    .user-dropdown-item:hover { background-color: var(--neutral-200); }
    .form-input, .form-select, .form-textarea { background: var(--neutral-200); color: #e2e8f0; }
    .table-header { background-color: var(--neutral-200); }
    table tbody tr:hover { background-color: var(--neutral-200); }
    .btn-secondary { background: var(--neutral-200); color: #e2e8f0; border-color: var(--neutral-300); }
    .btn-secondary:hover { background: var(--neutral-300); }
    .btn-ghost { color: #e2e8f0; }
    .btn-ghost:hover { background: var(--neutral-200); }
}

/* ----------------------------------------------------------------------- */
/*  Accessibility — Reduced Motion                                         */
/* ----------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .loading-spinner { animation: none; }
    .mobile-menu,
    .mobile-menu-overlay { transition: none; }
}

/* ----------------------------------------------------------------------- */
/*  Print Styles                                                           */
/* ----------------------------------------------------------------------- */
@media print {
    .app-header,
    .app-footer,
    .mobile-menu,
    .mobile-menu-overlay,
    .btn,
    .flash,
    .modal { display: none !important; }
    body { background: #fff !important; color: #000 !important; }
    .widget-card { box-shadow: none !important; border: 1px solid #ccc !important; }
}
