:root {
    /* Color Palette - Premium Eco Style */
    --primary: #005FAB;
    --primary-dark: #004a8b;
    --primary-light: #eef6fc;
    --accent: #ff7e39;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    /* Neutrals */
    --white: #ffffff;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    /* Effects */
    --shadow-premium: 0 10px 40px -10px rgba(0, 0, 0, 0.08);
    --shadow-float: 0 20px 50px -15px rgba(0, 95, 171, 0.12);
    --radius-xl: 32px;
    --radius-lg: 20px;
    --radius-md: 12px;
    --blur: 20px;

    /* Layout Constants */
    --header-h: 80px;
    --sidebar-w: 280px;
    --glass: rgba(255, 255, 255, 0.82);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    background: var(--bg-main);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: content-box;
}

/* Global Utilities */
.unauthorized body>.app-layout {
    display: none !important;
}

.unauthorized .header {
    background: transparent;
    border-bottom-color: rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

.unauthorized .logo-main,
.unauthorized .logo-sub {
    color: white;
}

.unauthorized .logo-icon {
    box-shadow: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.unauthorized #loginModal {
    display: flex;
}

#loginModal.hidden,
.unauthorized #loginModal.hidden {
    display: none !important;
}

.admin-link-hint {
    margin-top: 20px;
    font-size: 0.85rem;
    color: var(--text-light);
    cursor: pointer;
    transition: 0.2s;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.admin-link-hint:hover {
    color: var(--primary);
}

.unauthorized body {
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    min-height: 100vh;
}

/* --- HEADER --- */
.header {
    height: var(--header-h);
    background: var(--glass);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 3000;
    padding: 0 40px;
    display: flex;
    align-items: center;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: 0.3s;
}

.logo-container:hover {
    transform: scale(1.02);
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: var(--primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 16px rgba(0, 95, 171, 0.25);
}

.logo-main {
    display: block;
    font-weight: 850;
    font-size: 1.3rem;
    letter-spacing: -0.04em;
    color: var(--primary);
}

.logo-sub {
    display: block;
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-light);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.admin-status {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    padding: 8px 16px;
    border-radius: 100px;
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--success);
}

/* Buttons Header */
.btn-sync-premium {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 10px 25px -5px rgba(255, 126, 57, 0.3);
    transition: 0.3s;
}

.btn-sync-premium:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px -5px rgba(255, 126, 57, 0.4);
}

.btn-sync-premium svg {
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-sync-premium:hover svg {
    transform: rotate(360deg);
}

.btn-logout-header {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid var(--border);
    color: var(--danger);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
}

.btn-logout-header:hover {
    background: #fef2f2;
    border-color: #fee2e2;
}

/* --- LAYOUT --- */
.app-layout {
    display: flex;
    padding-top: var(--header-h);
    min-height: 100vh;
}

/* Sidebar */
.sidebar-premium {
    width: var(--sidebar-w);
    height: calc(100vh - var(--header-h));
    background: white;
    border-right: 1px solid rgba(0, 0, 0, 0.04);
    position: fixed;
    left: 0;
    padding: 32px 16px;
    z-index: 900;
    display: flex;
    flex-direction: column;
}

.sidebar-contact-info {
    margin-top: auto;
    padding-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-contact-info .contact-label {
    font-size: 0.72rem;
    color: var(--text-light);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-contact-info .contact-phone {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 750;
    font-size: 1.1rem;
    color: var(--text-main);
}

.sidebar-contact-socials {
    display: flex;
    gap: 12px;
    margin-top: 4px;
}

.sidebar-contact-socials a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid var(--border);
    transition: 0.2s;
}

.sidebar-contact-socials a:hover {
    background: white;
    border-color: rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}

.sidebar-contact-socials img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}


.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    border-radius: 14px;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-muted);
    transition: 0.2s;
}

.nav-link:hover {
    background: #f1f5f9;
    color: var(--primary);
}

.nav-link.active {
    background: var(--primary-light);
    color: var(--primary);
}

.section-divider {
    height: 1px;
    background: var(--border);
    margin: 24px 0;
    opacity: 0.5;
}

.sidebar-label {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-light);
    text-transform: uppercase;
    margin-left: 20px;
    letter-spacing: 0.1em;
    margin-bottom: 16px;
}

/* Upload Zone */
.upload-zone {
    width: 100%;
    border: 2px dashed var(--border);
    border-radius: 18px;
    padding: 16px;
    background: #fdfdfd;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    cursor: pointer;
    transition: 0.3s;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    color: var(--primary);
}

.upload-title {
    display: block;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-main);
}

.upload-sub {
    font-size: 0.7rem;
    color: var(--text-light);
}

.files-container {
    max-height: 180px;
    overflow-y: auto;
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 10px;
    margin-top: 12px;
    background: #fdfdfd;
}

.compact-file-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-icon-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.file-icon-item .btn-delete-file {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
    flex-shrink: 0;
}

.file-icon-item .btn-delete-file:hover {
    background: var(--danger);
    color: white;
}

/* --- MAIN STAGE --- */
.main-stage {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 48px 64px;
    min-width: 0;
}

.welcome-block {
    margin-bottom: 40px;
}

.welcome-block h1 {
    font-size: 2.8rem;
    font-weight: 850;
    letter-spacing: -0.05em;
    margin-bottom: 8px;
}

.highlight {
    color: var(--primary);
    position: relative;
}

.welcome-block .subtitle {
    color: var(--text-muted);
    font-size: 1.15rem;
    font-weight: 500;
}

/* Premium Search */
.premium-search-container {
    display: flex;
    gap: 24px;
    margin-bottom: 32px;
}

.search-bar-wrap {
    flex: 1;
    height: 68px;
    background: white;
    border-radius: 20px;
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 20px;
    box-shadow: var(--shadow-premium);
    border: 1px solid rgba(0, 0, 0, 0.02);
    transition: 0.3s;
}

.search-bar-wrap:focus-within {
    transform: translateY(-2px);
    box-shadow: var(--shadow-float);
    border-color: rgba(0, 95, 171, 0.2);
}

.search-bar-wrap input {
    border: none;
    outline: none;
    width: 100%;
    font-size: 1.15rem;
    font-weight: 500;
    color: var(--text-main);
}

.search-bar-wrap input::placeholder {
    color: var(--text-light);
}

.search-icon {
    color: var(--primary);
}

.btn-create-case {
    height: 68px;
    padding: 0 32px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 20px;
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0, 95, 171, 0.3);
    transition: 0.3s;
    white-space: nowrap;
}

.btn-create-case:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0, 95, 171, 0.4);
}

/* Filter Pills */
.filter-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    /* removed overflow */
    padding: 0 0 24px 0;
}

.pill {
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.03);
    padding: 10px 18px;
    border-radius: 100px;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
    display: flex;
    align-items: center;
    gap: 8px;
}

.pill:hover {
    background: #f8fafc;
    color: var(--primary);
    transform: translateY(-1px);
}

.pill.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 8px 20px rgba(0, 95, 171, 0.25);
    border-color: var(--primary);
}

/* --- CARDS GRID --- */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 32px;
}

.case-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: 32px;
    border: 1px solid rgba(0, 0, 0, 0.02);
    transition: all 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
}

.case-card:hover {
    transform: translateY(-8px) scale(1.01);
    box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.1);
}

.case-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.case-badge {
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.case-badge.floor {
    background: #eef2ff;
    color: #4338ca;
}

.case-badge.wall {
    background: #fff1f2;
    color: #be123c;
}

.case-badge.live {
    background: #fffbeb;
    color: #b45309;
}

.case-badge.mobile {
    background: #f0fdf4;
    color: #15803d;
}

.case-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: 0.3s;
}

.case-card:hover .case-actions {
    opacity: 1;
}

.btn-card-action {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.2s;
}

.btn-card-action:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary-light);
}

.btn-card-action.delete:hover {
    background: #fef2f2;
    color: var(--danger);
    border-color: #fee2e2;
}

.case-title {
    font-size: 1.5rem;
    font-weight: 850;
    letter-spacing: -0.03em;
    margin-bottom: 12px;
    line-height: 1.2;
}

.case-symptom {
    color: var(--text-muted);
    font-size: 1.05rem;
    margin-bottom: 28px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.case-meta-row {
    display: flex;
    gap: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
    margin-top: auto;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* --- MODALS PREMIUM --- */
.modal-premium {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 60px 20px;
    overflow-y: auto;
}

.modal-premium.active {
    display: flex;
}

.modal-blur {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(10px);
}

.modal-card {
    background: white;
    border-radius: var(--radius-xl);
    position: relative;
    z-index: 10;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.3);
    animation: modalIn 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-card.mini {
    width: 100%;
    max-width: 440px;
    padding: 48px;
    text-align: center;
}

.modal-card.large {
    width: 100%;
    max-width: 1100px;
    height: calc(100vh - 120px);
    /* Changed from max-height to height for consistency */
    max-height: calc(100vh - 120px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: white;
}


.modal-close-btn {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    font-size: 24px;
    cursor: pointer;
    transition: 0.2s;
    z-index: 100;
}

.modal-close-btn:hover {
    background: #e2e8f0;
    transform: rotate(90deg);
}

/* Case Details Layout */
.case-details-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    grid-template-rows: auto 1fr;
    height: 100%;
    overflow: hidden;
}

.case-details-header {
    padding: 48px 48px 0;
    grid-column: 1 / -1;
}

.detail-top-meta {
    margin-bottom: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.detail-main-title {
    font-size: 2.1rem;
    /* Slightly reduced from 2.4rem */
    font-weight: 850;
    letter-spacing: -0.04em;
    margin-bottom: 24px;
    /* Reduced from 32px */
    line-height: 1.25;
}


.detail-tabs {
    display: flex;
    gap: 32px;
    border-bottom: 2px solid #f1f5f9;
}

.detail-tab-btn {
    padding: 20px 0;
    border: none;
    background: none;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
}

.detail-tab-btn.active {
    color: var(--primary);
}

.detail-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
}

.case-details-body {
    padding: 16px 48px 100px;
    /* Increased bottom padding to 100px to ensure nothing is cut off */
    overflow-y: auto;
    background: white;
    min-height: 0;
}


.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.case-details-sidebar {
    background: #f8fafc;
    border-left: 1px solid #f1f5f9;
    padding: 48px 40px;
    overflow-y: auto;
    min-height: 0;
}


.info-block {
    margin-bottom: 32px;
}

.info-block label {
    display: block;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-light);
    letter-spacing: 0.1em;
    margin-bottom: 16px;
}

.stats-mini-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    flex-wrap: wrap;
}

.stat-pill {
    background: white;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid #f1f5f9;
}

.stat-val {
    display: block;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--primary);
}

.stat-lab {
    font-size: 0.7rem;
    color: var(--text-light);
}

.tags-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-item {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: 8px;
}

/* --- AI ASSISTANT PANEL --- */
.assistant-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 520px;
    background: white;
    z-index: 4000;
    transform: translateX(100%);
    transition: transform 0.6s cubic-bezier(0.19, 1, 0.22, 1);
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.assistant-panel.active {
    transform: translateX(0);
}

.assistant-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 3500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.assistant-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.assistant-header {
    padding: 32px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-branding {
    display: flex;
    align-items: center;
    gap: 16px;
}

.ai-avatar {
    width: 48px;
    height: 48px;
    background: var(--primary);
    color: white;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1.2rem;
}

/* Notifications */
.notification {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    padding: 16px 32px;
    border-radius: 14px;
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.2);
    animation: notifyIn 0.4s cubic-bezier(0.19, 1, 0.22, 1) forwards;
    white-space: nowrap;
    pointer-events: none;
}

@keyframes notifyIn {
    from {
        opacity: 0;
        transform: translate(-50%, -30px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.ai-title h4 {
    font-weight: 800;
    font-size: 1.1rem;
    margin-bottom: 2px;
}

.online-status {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 6px;
}

.online-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    display: block;
}

.assistant-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    background: #fafbfc;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Messages */
.message {
    display: flex;
    gap: 16px;
    max-width: 85%;
}

.message.bot-message {
    align-self: flex-start;
}

.message.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    flex-shrink: 0;
    overflow: hidden;
    background: #e2e8f0;
}

.message-content {
    padding: 16px 20px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 1rem;
    line-height: 1.5;
}

.bot-message .message-content {
    background: white;
    color: var(--text-main);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    border-bottom-left-radius: 4px;
}

.user-message .message-content {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.assistant-footer {
    padding: 24px 32px;
    background: white;
    border-top: 1px solid #f1f5f9;
}

.chat-input-wrap {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 8px 8px 8px 16px;
}

.chat-input-wrap textarea {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    padding: 10px 0;
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    max-height: 120px;
}

.btn-send-chat {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Loading State */
.loading-dots span {
    animation: blink 1.4s infinite both;
}

.loading-dots span:nth-child(2) {
    animation-delay: .2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: .4s;
}

@keyframes blink {
    0% {
        opacity: .2;
    }

    20% {
        opacity: 1;
    }

    100% {
        opacity: .2;
    }
}

/* Login Forms */
.auth-form {
    margin-top: 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-card.mini.auth-card {
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

.modal-card.mini.auth-card:hover {
    transform: translateY(-5px) scale(1.01);
}

.modal-card.mini.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    opacity: 0.8;
}

.input-glass-wrap {
    position: relative;
    width: 100%;
}

.input-glass-wrap svg {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    pointer-events: none;
    transition: 0.3s;
}

.input-glass-wrap input:focus+svg {
    color: var(--primary);
}

.input-glass-wrap input {
    width: 100%;
    height: 64px;
    padding-left: 54px;
    border-radius: 18px;
    border: 2px solid var(--border);
    background: white;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    transition: 0.3s;
}

.input-glass-wrap input::placeholder {
    font-size: 1rem;
    letter-spacing: normal;
    font-weight: 500;
    opacity: 0.5;
}

.input-glass-wrap input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.btn-submit-premium {
    width: 100%;
    height: 64px;
    border-radius: 18px;
    background: var(--primary);
    color: white;
    border: none;
    font-weight: 800;
    font-size: 1.1rem;
    margin-top: 24px;
    cursor: pointer;
    transition: 0.3s;
}

.btn-submit-premium:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 95, 171, 0.2);
}

/* Icons (Simplistic replacements) */
[class^="icon-"] {
    width: 22px;
    height: 22px;
    display: inline-block;
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.7;
}

.icon-home {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5'%3E%3Cpath d='m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/%3E%3Cpolyline points='9 22 9 12 15 12 15 22'/%3E%3C/svg%3E");
}

.icon-ai {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5'%3E%3Cpath d='M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5-10 5-10-5z'/%3E%3C/svg%3E");
}

/* Form Elements */
.form-header {
    padding: 40px 48px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.premium-form {
    flex: 1;
    overflow-y: auto;
    padding: 32px 48px 48px;
    display: flex;
    flex-direction: column;
}

.premium-form .form-group {
    margin-bottom: 24px;
}

.premium-form label {
    display: block;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: var(--text-main);
}

.premium-form input,
.premium-form select,
.premium-form textarea {
    width: 100%;
    padding: 14px 20px;
    border-radius: 14px;
    border: 1px solid var(--border);
    font-size: 1rem;
    font-family: inherit;
    transition: 0.2s;
}

.premium-form input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 4px var(--primary-light);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.form-footer {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    margin-top: 16px;
}

.btn-cancel {
    padding: 16px 28px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: white;
    font-weight: 700;
    cursor: pointer;
}

.btn-save {
    padding: 16px 32px;
    border-radius: 14px;
    background: var(--primary);
    color: white;
    border: none;
    font-weight: 700;
    cursor: pointer;
}

/* Responsive Grid Adjustments */
@media (max-width: 1400px) {
    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    }
}

@media (max-width: 1024px) {
    .sidebar-premium {
        width: 80px;
        padding: 32px 10px;
    }

    .nav-link span,
    .sidebar-label,
    .upload-info,
    .section-divider {
        display: none;
    }

    .main-stage {
        margin-left: 80px;
        padding: 40px;
    }
}

/* ADDITIONAL DETAIL STYLES */
.premium-step-item {
    display: flex;
    gap: 20px;
    background: #fff;
    padding: 24px;
    border-radius: 18px;
    margin-bottom: 16px;
    border: 1px solid #f1f5f9;
    transition: 0.2s;
}

.premium-step-item:hover {
    border-color: var(--primary-light);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.03);
}

.premium-step-item:hover .step-badge {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 95, 171, 0.3);
}

.step-badge {
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    flex-shrink: 0;
    transition: 0.2s cubic-bezier(0.19, 1, 0.22, 1);
}

.step-body {
    font-size: 1.05rem;
    color: var(--text-main);
    line-height: 1.6;
}

.stat-pill {
    background: white;
    padding: 16px;
    border-radius: 16px;
    border: 1px solid #f1f5f9;
    text-align: center;
}

.stat-val {
    display: block;
    font-weight: 850;
    font-size: 1.2rem;
    color: var(--primary);
    margin-bottom: 4px;
}

.stat-lab {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
}

.sys-item {
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.sys-item strong {
    color: var(--text-main);
    margin-right: 8px;
}

.tag-item {
    background: var(--primary-light);
    color: var(--primary);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
}

.empty-msg,
.empty-tags {
    color: var(--text-light);
    font-style: italic;
    font-size: 0.9rem;
}

/* Image Upload & Gallery */
.image-upload-zone {
    background: #f8fafc;
    border: 2px dashed var(--border);
    border-radius: 18px;
    padding: 24px;
    transition: 0.3s;
}

.image-upload-zone:focus-within {
    border-color: var(--primary);
    background: white;
}

.btn-upload-trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    border-radius: 12px;
    border: 2px solid var(--primary);
    background: transparent;
    color: var(--primary);
    font-weight: 700;
    cursor: pointer;
    transition: 0.3s;
    margin-bottom: 20px;
}

.btn-upload-trigger:hover {
    background: var(--primary);
    color: white;
}

.image-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 16px;
}

.preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-item .remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.case-images-gallery {
    display: flex;
    flex-direction: column;
    gap: 32px;
    padding-bottom: 60px;
    /* Отступ снизу */
}

.image-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    cursor: zoom-in;
}

.case-images-gallery img {
    max-width: 80%;
    /* Уменьшил на 20% */
    height: auto;
    border-radius: 20px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border);
    transition: 0.3s;
}

.image-wrapper::after {
    content: '🔍';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    font-size: 40px;
    opacity: 0;
    transition: 0.3s;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.3);
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    backdrop-filter: blur(4px);
}

.image-wrapper:hover img {
    filter: brightness(0.8);
}

.image-wrapper:hover::after {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    cursor: zoom-out;
    opacity: 0;
    transition: opacity 0.3s;
}

.lightbox.active {
    display: flex;
    opacity: 1;
}

.lightbox img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lightbox.active img {
    transform: scale(1);
}

.lightbox-close {
    position: absolute;
    top: 30px;
    right: 30px;
    color: white;
    font-size: 40px;
    cursor: pointer;
    line-height: 1;
}

.empty-gallery {
    padding: 40px;
    text-align: center;
    background: #f1f5f9;
    border-radius: 18px;
    color: var(--text-light);
    font-style: italic;
}

/* ============================================================
   HAMBURGER MENU BUTTON (hidden on desktop)
   ============================================================ */
.hamburger-btn {
    display: none;
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 10px;
    color: var(--text-main);
    transition: 0.2s;
}
.hamburger-btn:hover { background: #f1f5f9; }
.hamburger-btn svg { width: 24px; height: 24px; }

/* ============================================================
   MOBILE: <= 768px
   ============================================================ */
@media (max-width: 768px) {

    /* --- HEADER --- */
    .header { padding: 0 12px !important; height: 56px !important; }
    .logo-icon { width: 32px !important; height: 32px !important; border-radius: 8px !important; }
    .logo-icon svg { width: 16px !important; height: 16px !important; }
    .logo-main { font-size: 1rem !important; }
    .logo-sub { font-size: 0.6rem !important; }
    .logo-container { gap: 8px !important; }
    .header-actions { gap: 6px !important; }
    .admin-status { padding: 4px 8px !important; font-size: 0.7rem !important; }
    .btn-sync-premium { padding: 6px 10px !important; font-size: 0.75rem !important; border-radius: 8px !important; }
    .btn-sync-premium span { display: none !important; }
    .btn-logout-header { width: 32px !important; height: 32px !important; border-radius: 8px !important; }

    /* --- HAMBURGER visible --- */
    .hamburger-btn { display: flex !important; align-items: center; justify-content: center; }

    /* --- SIDEBAR: hidden by default, slide-over on open --- */
    .sidebar-premium {
        width: 280px !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        z-index: 5000 !important;
        top: 56px !important;
        height: calc(100vh - 56px) !important;
        height: calc(100dvh - 56px) !important;
        box-shadow: none !important;
        padding: 20px 16px 120px 16px !important;
        overflow-y: auto !important;
    }
    .sidebar-premium.mobile-open {
        transform: translateX(0) !important;
        box-shadow: 10px 0 40px rgba(0,0,0,0.2) !important;
    }

    /* Force show labels in mobile sidebar (override 1024px hide) */
    .sidebar-premium .nav-link span,
    .sidebar-premium .sidebar-label,
    .sidebar-premium .upload-info,
    .sidebar-premium .section-divider {
        display: block !important;
    }

    .sidebar-contact-info { padding-bottom: 24px !important; }

    /* Overlay behind sidebar */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        top: 56px;
        background: rgba(0,0,0,0.45);
        z-index: 4999;
        -webkit-backdrop-filter: blur(2px);
        backdrop-filter: blur(2px);
    }
    .sidebar-overlay.active { display: block; }

    /* --- MAIN STAGE: full width --- */
    .main-stage {
        margin-left: 0 !important;
        padding: 16px 14px !important;
    }

    /* --- WELCOME --- */
    .welcome-block { margin-bottom: 16px !important; }
    .welcome-block h1 { font-size: 1.5rem !important; }
    .welcome-block .subtitle { font-size: 0.85rem !important; }

    /* --- SEARCH --- */
    .premium-search-container { flex-direction: column !important; gap: 10px !important; margin-bottom: 14px !important; }
    .search-bar-wrap {
        height: 46px !important;
        border-radius: 12px !important;
        padding: 0 14px !important;
        gap: 10px !important;
    }
    .search-bar-wrap input { font-size: 0.9rem !important; }
    .btn-create-case {
        height: 42px !important;
        border-radius: 12px !important;
        font-size: 0.85rem !important;
        padding: 0 16px !important;
        justify-content: center !important;
    }

    /* --- FILTER PILLS: horizontal scroll --- */
    .filter-pills {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding-bottom: 10px !important;
        gap: 6px !important;
        scrollbar-width: none !important;
    }
    .filter-pills::-webkit-scrollbar { display: none !important; }
    .pill { padding: 7px 12px !important; font-size: 0.78rem !important; flex-shrink: 0 !important; }
    .pill-icon { display: none !important; }

    /* --- CARDS: single column --- */
    .cards-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    .case-card {
        padding: 16px !important;
        border-radius: 16px !important;
    }
    .case-card:hover { transform: none !important; }
    .case-actions { opacity: 1 !important; }
    .case-title { font-size: 1rem !important; }
    .case-meta { font-size: 0.78rem !important; }

    /* --- MODALS: full screen --- */
    .modal-premium {
        align-items: stretch !important;
        padding: 0 !important;
    }
    .modal-card {
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }
    .modal-card.large {
        overflow-y: auto !important;
        display: flex !important;
        flex-direction: column !important;
    }
    .modal-card.mini { height: auto !important; max-height: 100vh !important; }

    /* Login modal — keep card style */
    .modal-card.mini.auth-card {
        max-width: calc(100% - 32px) !important;
        border-radius: 20px !important;
        margin: auto 16px !important;
        height: auto !important;
    }

    /* --- CASE DETAILS: stack vertically --- */
    .case-details-layout {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: 1fr !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        height: auto !important;
        min-height: 0 !important;
    }
    .case-details-header {
        padding: 16px !important;
        grid-column: auto !important;
    }
    .case-details-body {
        padding: 16px !important;
        overflow: visible !important;
        min-height: auto !important;
    }
    .case-details-sidebar {
        width: 100% !important;
        border-left: none !important;
        border-top: 1px solid var(--border) !important;
        padding: 16px !important;
        overflow: visible !important;
    }
    .detail-main-title { font-size: 1.15rem !important; line-height: 1.3 !important; }
    .detail-top-meta { font-size: 0.75rem !important; }
    .detail-tabs { gap: 4px !important; }
    .detail-tab-btn { padding: 10px 0 !important; font-size: 0.85rem !important; gap: 16px !important; }

    .premium-step-item { padding: 12px !important; gap: 10px !important; border-radius: 12px !important; }
    .step-body { font-size: 0.88rem !important; word-break: break-word !important; }
    .case-images-gallery img { max-width: 100% !important; border-radius: 12px !important; }

    .modal-close-btn { width: 34px !important; height: 34px !important; font-size: 22px !important; top: 10px !important; right: 10px !important; }
    .stats-mini-grid { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
    .tags-cloud { gap: 6px !important; }
    .tag-item { padding: 4px 8px !important; font-size: 0.75rem !important; }

    /* --- CREATE/EDIT MODAL --- */
    .premium-form .form-row { flex-direction: column !important; gap: 0 !important; }
    .form-header h2 { font-size: 1.2rem !important; }
    .form-footer { flex-direction: column !important; gap: 8px !important; }
    .form-footer .btn-cancel,
    .form-footer .btn-save { width: 100% !important; justify-content: center !important; }

    /* --- AI PANEL: full screen --- */
    .assistant-panel {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 0 !important;
        height: calc(100vh - 56px) !important;
        height: calc(100dvh - 56px) !important;
        top: 56px !important;
    }
    .assistant-header { padding: 10px 14px !important; }
    .ai-title h4 { font-size: 0.9rem !important; }
    .assistant-chat-body { padding: 14px !important; }
    .assistant-footer { padding: 10px 14px !important; }
    .chat-input-wrap textarea { font-size: 0.9rem !important; }

    /* --- LIGHTBOX --- */
    .lightbox img { max-width: 96% !important; max-height: 80% !important; border-radius: 6px !important; }
    .lightbox-close { top: 12px !important; right: 12px !important; font-size: 28px !important; }
}