/* =============================================
   ADEC SENSOR NETWORK TRACKER
   Design: Clean Professional
   Navy + slate + white
   ============================================= */

/* ===== GLOBAL ACCESSIBILITY ===== */
:focus-visible {
    outline: 2px solid var(--navy-500);
    outline-offset: 2px;
}

button:focus-visible, .btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(37, 99, 176, 0.3);
    outline: none;
}

.skip-nav {
    position: absolute;
    left: -9999px;
    top: 4px;
    z-index: 10000;
    background: var(--navy-800);
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

.skip-nav:focus {
    left: 16px;
}

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* ===== DESIGN TOKENS ===== */
:root {
    --slate-950: #0a0f1a;
    --slate-900: #0f1923;
    --slate-800: #162032;
    --slate-700: #1e2d42;
    --slate-600: #334155;
    --slate-500: #475569;
    --slate-400: #94a3b8;
    --slate-300: #cbd5e1;
    --slate-200: #e2e8f0;
    --slate-100: #f1f5f9;
    --slate-50: #f8fafc;

    --navy-800: #1e2a4a;
    --navy-700: #1e3a5f;
    --navy-600: #1e4d8c;
    --navy-500: #2563b0;
    --navy-400: #3b7dd8;
    --navy-300: #6ba0e6;
    --navy-200: #b3d0f5;
    --navy-100: #dce9f8;

    --gold-600: #a8872e;
    --gold-500: #C9A84C;
    --gold-400: #d4b968;
    --gold-300: #e3d192;
    --gold-100: #faf5e4;
    --navy-50: #f0f2f7;
    --slate-25: #fafbfc;

    --aurora-green: #22c55e;
    --aurora-rose: #f43f5e;
    --aurora-amber: #f59e0b;
    --aurora-violet: #a78bfa;

    --surface: #ffffff;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 2px rgba(15, 25, 35, 0.04), 0 1px 3px rgba(15, 25, 35, 0.06);
    --shadow-md: 0 2px 8px rgba(15, 25, 35, 0.06), 0 4px 16px rgba(15, 25, 35, 0.04);
    --shadow-lg: 0 4px 12px rgba(15, 25, 35, 0.07), 0 12px 40px rgba(15, 25, 35, 0.08);
    --shadow-xl: 0 8px 24px rgba(15, 25, 35, 0.1), 0 24px 60px rgba(15, 25, 35, 0.12);

    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-sans);
    background: var(--slate-100);
    color: var(--slate-800);
    height: 100vh;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    display: flex;
    height: 100vh;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: var(--slate-400); }
#sidebar::-webkit-scrollbar-thumb { background: var(--slate-700); }
#sidebar::-webkit-scrollbar-thumb:hover { background: var(--slate-600); }

/* ===== SIDEBAR ===== */
#sidebar {
    width: 272px;
    min-width: 272px;
    background: linear-gradient(195deg, var(--slate-900) 0%, var(--slate-950) 100%);
    color: var(--slate-300);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    position: relative;
}

#sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(180deg, var(--navy-400) 0%, transparent 40%, transparent 60%, var(--navy-600) 100%);
    opacity: 0.3;
}

.sidebar-header {
    padding: 20px 20px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(180deg, rgba(37, 99, 176, 0.06) 0%, transparent 100%);
}

.sidebar-logo {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    filter: brightness(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.sidebar-header h2 {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--gold-300);
    letter-spacing: 0.02em;
    line-height: 1.4;
    opacity: 0.9;
}

.sidebar-menu {
    list-style: none;
    padding: 8px 8px;
    flex: 1;
}

.sidebar-menu > li {
    margin-bottom: 1px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: var(--slate-300);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 450;
    letter-spacing: 0.01em;
    transition: all 0.2s var(--ease-out);
    cursor: pointer;
    border-radius: var(--radius-sm);
    position: relative;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
}

.menu-item.active {
    background: rgba(37, 99, 176, 0.12);
    color: var(--gold-300);
}

.menu-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    background: var(--gold-400);
    border-radius: 0 2px 2px 0;
}

.menu-item .icon {
    font-size: 13px;
    width: 18px;
    text-align: center;
    opacity: 0.7;
}

/* Sidebar community menu item layout */
.community-menu-item {
    position: relative;
}

.community-nav-label {
    flex: 1;
}

.community-toggle-arrow {
    font-size: 9px;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.2s var(--ease-out);
    opacity: 0.5;
    line-height: 1;
}

.community-toggle-arrow:hover {
    background: rgba(255, 255, 255, 0.1);
    opacity: 1;
}

.community-toggle-arrow.open {
    transform: rotate(180deg);
}

.community-list {
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s var(--ease-out);
}

.community-list.open {
    max-height: 600px;
}

.community-list li a {
    display: block;
    padding: 7px 14px 7px 44px;
    color: var(--slate-400);
    text-decoration: none;
    font-size: 13px;
    font-weight: 400;
    transition: all 0.2s var(--ease-out);
    border-radius: var(--radius-sm);
    margin: 0 8px;
    position: relative;
}

.community-list li a::before {
    content: '';
    position: absolute;
    left: 32px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--slate-500);
    transition: all 0.2s var(--ease-out);
}

.community-list li a:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--slate-200);
}

.community-list li a:hover::before {
    background: var(--gold-400);
}

.community-list li a.active {
    color: var(--gold-300);
    background: rgba(37, 99, 176, 0.08);
}

.community-list li a.active::before {
    background: var(--gold-400);
    box-shadow: 0 0 6px rgba(37, 99, 176, 0.4);
}

/* ===== COMMUNITY TAG FILTERS (top of communities page) ===== */
.community-tag-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.community-tag-filter-btn {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    border-left: 3px solid var(--slate-300);
    background: var(--slate-50, #f8fafc);
    color: var(--slate-500);
    transition: all 0.2s var(--ease-out);
    font-family: var(--font-sans);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.community-tag-filter-btn:hover {
    border-left-color: #1B2A4A;
    color: #1B2A4A;
    background: var(--slate-100, #f1f5f9);
    box-shadow: none;
}

.community-tag-filter-btn.active {
    background: var(--slate-100, #f1f5f9);
    border-left-color: #1B2A4A;
    color: #1B2A4A;
    box-shadow: none;
}

/* ===== CONTACT STATUS TOGGLE ===== */
.contact-status-toggle {
    display: flex;
    gap: 8px;
}

.contact-status-option {
    flex: 1;
    cursor: pointer;
}

.contact-status-option input[type="radio"] {
    display: none;
}

.contact-status-label {
    display: block;
    text-align: center;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    border: 1px solid var(--slate-200);
    transition: all 0.15s var(--ease-out);
}

.contact-status-option input[type="radio"]:checked + .active-label {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.4);
    color: #15803d;
}

.contact-status-option input[type="radio"]:checked + .inactive-label {
    background: rgba(148, 163, 184, 0.15);
    border-color: var(--slate-300);
    color: var(--slate-500);
}

.contact-email-list-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.contact-email-list-label input[type="checkbox"] {
    accent-color: var(--gold-500);
    width: 16px;
    height: 16px;
}

.contact-row-inactive td {
    opacity: 0.45;
}

.contact-row-inactive td:last-child {
    opacity: 1;
}

.contact-inactive-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 7px;
    border-radius: 100px;
    background: rgba(148, 163, 184, 0.15);
    color: var(--slate-500);
    margin-left: 6px;
}

.contact-primary-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 7px;
    border-radius: 100px;
    background: rgba(184, 155, 56, 0.15);
    color: var(--gold-600, #92710a);
    margin-left: 6px;
}

/* ===== SENSOR TYPE PICKER ===== */
.type-change-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.type-option-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-sans);
    color: var(--slate-700);
    cursor: pointer;
    transition: all 0.15s var(--ease-out);
}

.type-option-btn:hover:not(:disabled) {
    border-color: var(--navy-400);
    background: var(--navy-100);
    color: var(--navy-700);
    box-shadow: var(--shadow-sm);
}

.type-option-btn.current {
    border-color: var(--gold-400);
    background: var(--gold-100);
    color: var(--gold-600);
    cursor: default;
}

.type-option-current {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gold-600);
}

/* ===== INLINE EDITING (setup mode) ===== */
.inline-edit-input {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--slate-200);
    border-radius: 4px;
    font-size: 12.5px;
    font-family: var(--font-sans);
    color: var(--slate-700);
    background: var(--surface);
    transition: border-color 0.15s ease;
    min-width: 80px;
}

.inline-edit-input:focus {
    outline: none;
    border-color: var(--gold-400);
    box-shadow: 0 0 0 2px rgba(71, 85, 105, 0.15);
}

.inline-edit-select {
    width: 100%;
    padding: 5px 6px;
    border: 1px solid var(--slate-200);
    border-radius: 4px;
    font-size: 12px;
    font-family: var(--font-sans);
    color: var(--slate-700);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.15s ease;
    min-width: 100px;
}

.inline-edit-select:focus {
    outline: none;
    border-color: var(--gold-400);
    box-shadow: 0 0 0 2px rgba(71, 85, 105, 0.15);
}

.inline-edit-sm {
    min-width: 0;
    width: auto;
    font-size: 11px;
    padding: 2px 4px;
    margin-top: 3px;
    color: var(--slate-500);
}

.inline-edit-status {
    min-height: 60px;
    font-size: 11px;
}

/* ===== SETUP MODE TOGGLE ===== */
.setup-mode-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    margin: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--slate-300);
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: all 0.2s var(--ease-out);
}

.setup-mode-toggle:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #ffffff;
}

.setup-mode-toggle.active {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--aurora-amber);
}

.setup-mode-icon {
    font-size: 14px;
}

/* ===== MAIN WRAPPER (tab bar + content) ===== */
#main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 0% 0%, rgba(37, 99, 176, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 100% 100%, rgba(37, 99, 176, 0.02) 0%, transparent 50%),
        var(--slate-100);
}

/* ===== OPEN TABS BAR ===== */
.open-tabs-bar {
    display: none;
    align-items: flex-start;
    gap: 0;
    padding: 0 36px;
    background: var(--slate-50);
    border-bottom: 1px solid var(--slate-200);
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}

.open-tabs-bar::-webkit-scrollbar {
    display: none;
}

.open-tabs-bar.visible {
    display: flex;
}

.open-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--slate-500);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s var(--ease-out);
    max-width: 200px;
    white-space: nowrap;
    position: relative;
    font-family: var(--font-sans);
    flex-shrink: 0;
}

.open-tab:hover {
    background: rgba(255, 255, 255, 0.6);
    color: var(--slate-700);
}

.open-tab.active {
    background: var(--surface);
    color: var(--navy-700);
    font-weight: 600;
    border-bottom-color: var(--navy-500);
}

.open-tab-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.open-tab-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    font-size: 12px;
    line-height: 1;
    color: var(--slate-400);
    transition: all 0.15s var(--ease-out);
    flex-shrink: 0;
}

.open-tab-close:hover {
    background: rgba(244, 63, 94, 0.12);
    color: var(--aurora-rose);
}

.open-tab-icon {
    font-size: 10px;
    opacity: 0.6;
    flex-shrink: 0;
}

.open-tab-group {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.open-tab-group .open-tab {
    border-bottom: none;
}

.open-tab-group .open-tab.active {
    border-bottom: none;
}

.open-tab-children {
    display: flex;
    gap: 0;
    border-bottom: 2px solid transparent;
}

.open-tab-children .open-tab-child {
    font-size: 11px;
    padding: 5px 10px;
    color: var(--slate-400);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s var(--ease-out);
    white-space: nowrap;
    font-family: var(--font-sans);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border-left: 1px solid var(--slate-200);
}

.open-tab-children .open-tab-child:first-child {
    border-left: none;
    padding-left: 14px;
}

.open-tab-children .open-tab-child:hover {
    color: var(--slate-600);
    background: rgba(255, 255, 255, 0.5);
}

.open-tab-children .open-tab-child.active {
    color: var(--navy-600);
    font-weight: 600;
    border-bottom-color: var(--navy-400);
}

.open-tab-children .open-tab-child .open-tab-close {
    width: 14px;
    height: 14px;
    font-size: 10px;
}

/* ===== MAIN CONTENT ===== */
#main-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px 20px;
}

.view {
    display: none;
    animation: viewFadeIn 0.35s var(--ease-out);
}

.view.active {
    display: block;
}

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

.view-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.view-header h1 {
    font-size: 22px;
    font-weight: 600;
    color: var(--slate-900);
    letter-spacing: -0.02em;
}

/* ===== DASHBOARD ===== */
.dashboard-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.dash-stat {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.04);
    text-align: center;
    cursor: pointer;
    transition: all 0.15s var(--ease-out);
}

.dash-stat:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.dash-stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--slate-900);
    font-variant-numeric: tabular-nums;
}

.dash-stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--slate-400);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 2px;
}

.dash-stat-issue .dash-stat-value { color: var(--aurora-rose); }

.map-iframe-full {
    width: 100%;
    height: calc(100vh - 200px);
    border: none;
    border-radius: var(--radius-lg);
}

/* ===== MOBILE ===== */
.mobile-header {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 101;
    gap: 6px;
}

.hamburger-btn {
    background: var(--slate-900);
    border: none;
    color: var(--slate-200);
    font-size: 18px;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    line-height: 1;
}

.hamburger-btn:active {
    background: var(--slate-800);
}



.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-bottom-actions {
    margin-top: auto;
    padding: 4px 0;
}


@media (max-width: 768px) {
    .mobile-header { display: flex; }
    #sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 272px;
        min-width: 0;
        z-index: 100;
        transition: left 0.3s var(--ease-out);
    }
    #sidebar.mobile-open { left: 0; }
    .sidebar-overlay.visible { display: block; }
    #main-wrapper { width: 100vw; min-width: 0; flex: 1; }
    #main-content { padding: 16px; padding-top: 52px; }
    .view-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .global-search-bar { padding: 8px 16px; }
    .dashboard-summary { grid-template-columns: repeat(2, 1fr); }
    .community-detail-toolbar { flex-wrap: wrap; }
    .analysis-chart-grid { grid-template-columns: 1fr; }
    .ticket-detail-grid { grid-template-columns: 1fr; }
    .modal-content { max-width: 95%; }
    .modal-content.modal-lg, .modal-content.modal-xl { max-width: 95%; }
    .open-tabs-bar { display: none; }
    .sensor-info-card, .contact-info-card { overflow-x: auto; }
    .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
    .analysis-chart-card { padding-left: 24px; }
    .dqo-summary-table { min-width: 600px; }
}

/* ===== COMMUNITIES LIST ===== */
.community-row {
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 12px 18px;
    margin-bottom: 2px;
    border: 1px solid rgba(0, 0, 0, 0.04);
    cursor: pointer;
    transition: all 0.15s var(--ease-out);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.community-row:hover {
    background: rgba(37, 99, 176, 0.03);
    border-color: var(--navy-200);
}

.parent-row {
    padding: 14px 18px;
    background: var(--surface);
    border-radius: var(--radius-md);
    margin-bottom: 0;
    border-bottom: none;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.parent-row + .child-list {
    margin-bottom: 8px;
}

.parent-row + .child-list:not(.open) + .community-row,
.parent-row + .child-list:not(.open) + .parent-row {
    margin-top: 2px;
}

.parent-expand-arrow {
    font-size: 10px;
    color: var(--slate-400);
    transition: transform 0.2s var(--ease-out);
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    padding: 4px;
    border-radius: 4px;
}

.parent-expand-arrow:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--slate-600);
}

.parent-expand-arrow.open {
    transform: rotate(90deg);
}

.child-list {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s var(--ease-out);
    padding-left: 28px;
    border-left: 2px solid var(--navy-200);
    margin-left: 26px;
}

.child-list.open {
    max-height: 800px;
}

.child-row {
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    margin-bottom: 1px;
    border: none;
    background: var(--slate-50);
}

.child-row:hover {
    background: rgba(37, 99, 176, 0.06);
}

.child-row .community-row-name {
    font-size: 13.5px;
    font-weight: 500;
}

.community-row-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
    flex: 1;
}

.community-row-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--slate-800);
    white-space: nowrap;
}

.community-row-meta {
    font-size: 12px;
    color: var(--slate-400);
    font-weight: 500;
    white-space: nowrap;
}

.community-row-sensors {
    font-size: 12px;
    font-family: var(--font-mono);
    font-weight: 500;
    color: var(--navy-600);
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
    flex-shrink: 0;
}

.community-row .community-type-badge {
    font-size: 9px;
    padding: 2px 8px;
}

.community-row .community-card-tags {
    display: inline-flex;
    gap: 4px;
}

/* ===== ADD SUB-COMMUNITY LINK ===== */
.add-sub-community-link {
    font-size: 12px;
    font-weight: 500;
    color: var(--slate-400);
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s ease;
}

.add-sub-community-link:hover {
    color: var(--navy-600);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ===== SITE GROUPS (parent community sensor view) ===== */
.site-group {
    margin-bottom: 24px;
}

.site-group-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--slate-800);
    padding: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.site-group-count {
    font-size: 12px;
    font-weight: 500;
    color: var(--slate-400);
}

.site-group-table {
    margin-left: 16px;
}

/* ===== SUB-COMMUNITIES ===== */
.community-parent-breadcrumb {
    font-size: 16px;
    font-weight: 400;
    color: var(--slate-400);
}

.community-parent-breadcrumb .clickable {
    color: var(--slate-400);
    font-weight: 500;
}

.community-parent-breadcrumb .clickable:hover {
    color: var(--navy-600);
}

/* ===== TABLES ===== */
.table-container {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: var(--slate-50);
    text-align: left;
    padding: 12px 18px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--slate-400);
    border-bottom: 1px solid var(--slate-200);
    white-space: nowrap;
}

td {
    padding: 14px 18px;
    font-size: 13.5px;
    border-bottom: 1px solid var(--slate-100);
    color: var(--slate-700);
}

tr {
    transition: background 0.15s ease;
}

tr:hover {
    background: rgba(37, 99, 176, 0.02);
}

tr:last-child td {
    border-bottom: none;
}

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    gap: 5px;
}

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

.badge-online { background: rgba(34, 197, 94, 0.1); color: #15803d; }
.badge-online::before { background: #22c55e; box-shadow: 0 0 6px rgba(34, 197, 94, 0.4); }

.badge-offline { background: rgba(148, 163, 184, 0.15); color: #475569; }
.badge-offline::before { background: #94a3b8; }

.badge-transit { background: rgba(148, 163, 184, 0.12); color: #64748b; }
.badge-transit::before { background: #94a3b8; }

.badge-collocation { background: rgba(59, 130, 246, 0.1); color: #1d4ed8; }
.badge-collocation::before { background: #3b82f6; }

.badge-auditing { background: rgba(139, 92, 246, 0.1); color: #5b21b6; }
.badge-auditing::before { background: #8b5cf6; }

.badge-lab-storage { background: rgba(51, 65, 85, 0.12); color: #1e293b; }
.badge-lab-storage::before { background: #334155; }

.badge-needs-repair { background: rgba(249, 115, 22, 0.1); color: #c2410c; }
.badge-needs-repair::before { background: #f97316; }

.badge-ready { background: rgba(22, 163, 74, 0.12); color: #14532d; }
.badge-ready::before { background: #16a34a; }

.badge-issue-yellow { background: rgba(234, 179, 8, 0.1); color: #a16207; }
.badge-issue-yellow::before { background: #eab308; }

.badge-issue-orange { background: rgba(249, 115, 22, 0.1); color: #c2410c; }
.badge-issue-orange::before { background: #f97316; }

.badge-issue-red { background: rgba(239, 68, 68, 0.1); color: #b91c1c; }
.badge-issue-red::before { background: #ef4444; box-shadow: 0 0 6px rgba(239, 68, 68, 0.4); }

.badge-clickable {
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}

.badge-clickable:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.community-type-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    background: var(--slate-50, #f8fafc);
    color: #1B2A4A;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-left: 3px solid #1B2A4A;
}

.clickable-badge {
    cursor: pointer;
    transition: all 0.15s var(--ease-out);
}

.clickable-badge:hover {
    background: var(--slate-100, #f1f5f9);
    transform: none;
    border-left-color: #C9A84C;
}

.community-tags-container {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.community-card-tags {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.community-card-tags .community-type-badge {
    font-size: 10px;
    padding: 2px 8px;
}

.community-tag-edit {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    color: #C9A84C;
    cursor: pointer;
    padding: 3px 10px;
    border-radius: 3px;
    border: 1px dashed #C9A84C;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: all 0.15s var(--ease-out);
}

.community-tag-edit:hover {
    background: rgba(201, 168, 76, 0.08);
    border-style: solid;
}

.tag-filter-banner {
    padding: 10px 16px;
    background: var(--navy-100);
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--navy-700);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

.edit-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
}

.edit-tag-option {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    border: 1px solid var(--slate-200);
    background: var(--surface);
    color: var(--slate-500);
    transition: all 0.2s var(--ease-out);
}

.edit-tag-option:hover {
    border-color: var(--navy-300);
    color: #1B2A4A;
    border-left: 3px solid #1B2A4A;
}

.edit-tag-option.active {
    background: var(--slate-50, #f8fafc);
    border-color: var(--slate-200);
    border-left: 3px solid #1B2A4A;
    color: #1B2A4A;
    font-weight: 700;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 8px 16px;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--slate-700);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    background: var(--slate-50);
    border-color: var(--slate-300);
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background: linear-gradient(135deg, var(--navy-500), var(--navy-600));
    color: #fff;
    border: none;
    box-shadow: 0 1px 3px rgba(30, 74, 140, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--navy-400), var(--navy-600));
    box-shadow: 0 4px 12px rgba(30, 74, 140, 0.3);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 5px;
}

.btn-danger {
    color: var(--aurora-rose);
    border-color: rgba(244, 63, 94, 0.25);
}

.btn-danger:hover {
    background: var(--aurora-rose);
    color: #fff;
    border-color: var(--aurora-rose);
}

/* ===== FILTER BAR ===== */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.filter-bar input, .filter-bar select {
    padding: 9px 14px;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: var(--font-sans);
    background: var(--surface);
    color: var(--slate-700);
    transition: all 0.2s var(--ease-out);
}

.filter-bar input:focus, .filter-bar select:focus {
    outline: none;
    border-color: var(--gold-400);
    box-shadow: 0 0 0 3px rgba(37, 99, 176, 0.12);
}

.filter-bar input {
    flex: 1;
    max-width: 320px;
}

.filter-bar input::placeholder {
    color: var(--slate-400);
}

/* ===== TABS ===== */
.tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--slate-200);
    flex-wrap: wrap;
}

.tab {
    padding: 10px 18px;
    background: none;
    border: none;
    font-size: 13.5px;
    font-weight: 500;
    font-family: var(--font-sans);
    color: var(--slate-400);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s var(--ease-out);
    letter-spacing: 0.01em;
}

.tab:hover {
    color: var(--slate-600);
}

.tab.active {
    color: var(--navy-600);
    border-bottom-color: var(--navy-500);
    font-weight: 600;
}

.tab-content {
    display: none;
    animation: tabFade 0.25s var(--ease-out);
}

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

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

/* ===== TIMELINE / HISTORY ===== */
.timeline {
    position: relative;
    padding-left: 28px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 9px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, var(--navy-200) 0%, var(--slate-200) 100%);
    border-radius: 2px;
}

.timeline-item {
    position: relative;
    padding: 18px 22px;
    background: var(--surface);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.04);
    transition: all 0.2s var(--ease-out);
}

.timeline-item:hover {
    box-shadow: var(--shadow-md);
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -23px;
    top: 24px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--navy-500);
    border: 2.5px solid var(--slate-100);
    box-shadow: 0 0 0 2px rgba(37, 99, 176, 0.2);
}

.timeline-item.type-audit::before { background: var(--navy-400); box-shadow: 0 0 0 2px rgba(59, 125, 216, 0.2); }
.timeline-item.type-movement::before { background: var(--aurora-amber); box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2); }
.timeline-item.type-issue::before { background: var(--aurora-rose); box-shadow: 0 0 0 2px rgba(244, 63, 94, 0.2); }
.timeline-item.type-comm::before { background: var(--aurora-green); box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2); }
.timeline-item.type-status::before { background: var(--aurora-violet); box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.2); }
.timeline-item.type-edit::before { background: var(--gold-500); box-shadow: 0 0 0 2px rgba(71, 85, 105, 0.2); }

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.timeline-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.timeline-item:hover .timeline-actions {
    opacity: 1;
}

.timeline-action-btn {
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background 0.1s ease;
    opacity: 0.4;
}

.timeline-action-btn:hover {
    opacity: 1;
    background: rgba(244, 63, 94, 0.1);
}

.timeline-date {
    font-size: 12px;
    color: var(--slate-400);
    margin-bottom: 5px;
    font-weight: 500;
}

.timeline-type {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--slate-100);
    color: var(--slate-500);
    margin-bottom: 8px;
}

.timeline-text {
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--slate-700);
}

.timeline-followups {
    margin-top: 10px;
    border-top: 1px solid var(--slate-100);
    padding-top: 8px;
}
.timeline-followup-entry {
    padding: 8px 12px;
    margin-top: 6px;
    background: var(--slate-50);
    border-left: 3px solid var(--navy-300);
    border-radius: 0 6px 6px 0;
    font-size: 13px;
    line-height: 1.5;
    position: relative;
}
.followup-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.timeline-followup-entry strong {
    color: var(--navy-500);
    font-size: 12px;
}
.timeline-followup-date {
    font-size: 11px;
    color: var(--slate-400);
    margin-left: 4px;
}
.timeline-followup-text {
    color: var(--slate-600);
    margin-top: 2px;
}
.followup-actions {
    display: none;
    gap: 4px;
}
.timeline-followup-entry:hover .followup-actions {
    display: flex;
}
.followup-action-btn {
    cursor: pointer;
    font-size: 12px;
    color: var(--slate-300);
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}
.followup-action-btn:hover {
    color: var(--slate-600);
    background: var(--slate-100);
}

.timeline-text-preview {
    cursor: pointer;
}

.timeline-text-full {
    display: none;
    margin-top: 10px;
    padding: 14px;
    background: var(--slate-50);
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.7;
    white-space: pre-wrap;
    color: var(--slate-600);
    border: 1px solid var(--slate-200);
}

.timeline-text-full.open {
    display: block;
}

.timeline-tags {
    margin-top: 10px;
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.tag {
    font-size: 11px;
    font-weight: 500;
    padding: 3px 9px;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}

.tag:hover {
    transform: scale(1.05);
}

.tag-sensor { background: rgba(37, 99, 176, 0.1); color: var(--navy-700); font-family: var(--font-mono); font-size: 10.5px; }
.tag-community { background: rgba(34, 197, 94, 0.08); color: #15803d; }
.tag-contact { background: rgba(167, 139, 250, 0.1); color: #6d28d9; }

.history-actions {
    margin-bottom: 18px;
}

/* ===== CONTACTS TABLE FIXED WIDTHS ===== */
.contacts-table {
    table-layout: fixed;
    width: 100%;
}

.contacts-table th,
.contacts-table td {
    white-space: normal;
    word-break: break-word;
    vertical-align: top;
    padding: 8px 6px;
}

.contacts-table .col-name       { width: 18%; }
.contacts-table .col-role       { width: 14%; }
.contacts-table .col-org        { width: 13%; }
.contacts-table .col-email      { width: 27%; overflow: visible; }
.contacts-table .col-phone      { width: 12%; white-space: nowrap; }
.contacts-table .col-status     { width: 6%; white-space: nowrap; }
.contacts-table .col-actions    { width: 4%; text-align: center; padding: 0; }

.contacts-table .col-name .contact-primary-badge { vertical-align: middle; }

.primary-toggle {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-top: 3px;
    cursor: pointer;
    font-size: 10px;
}
.primary-toggle input[type="checkbox"] {
    accent-color: var(--gold-500);
    width: 13px;
    height: 13px;
    cursor: pointer;
}
.primary-toggle-label {
    color: var(--slate-400);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.primary-toggle input:checked + .primary-toggle-label {
    color: var(--gold-600);
    font-weight: 600;
}

/* Email cell: email address + inline checkbox */
.email-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.email-cell a {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.email-list-toggle {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: auto;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s;
}

.email-list-toggle:hover {
    background: var(--gold-100);
}

.email-list-toggle .email-list-checkbox {
    width: 13px;
    height: 13px;
    accent-color: var(--gold-500);
    cursor: pointer;
    margin: 0;
}

.email-list-toggle .email-list-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--slate-400);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    user-select: none;
}

.email-list-toggle:has(.email-list-checkbox:checked) .email-list-label {
    color: var(--gold-600);
}

/* Delete icon — hidden until row hover */
.contact-delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    color: var(--slate-300);
    font-size: 15px;
    cursor: pointer;
    border-radius: 6px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}

tr:hover .contact-delete-btn {
    opacity: 1;
}

.contact-delete-btn:hover {
    color: var(--aurora-rose);
    background: rgba(244, 63, 94, 0.08);
}

.editable-group-name {
    cursor: pointer;
    border-bottom: 1px dashed var(--gold-400);
    padding-bottom: 1px;
    transition: color 0.15s;
}

.editable-group-name:hover {
    color: var(--gold-600);
}

.group-edit-icon {
    font-size: 11px;
    opacity: 0.4;
    margin-left: 4px;
    transition: opacity 0.15s;
}

.editable-group-name:hover .group-edit-icon {
    opacity: 1;
}

.contacts-tab-description {
    font-size: 13px;
    color: var(--slate-500);
    padding: 12px 16px;
    background: var(--slate-25);
    border: 1px solid var(--slate-100);
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    line-height: 1.5;
}

/* ===== CONTACTS (grouped by community) ===== */
.contacts-group {
    margin-bottom: 28px;
}

.contacts-group-header {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--slate-400);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--slate-200);
    display: flex;
    align-items: center;
    gap: 8px;
}

.contacts-group-header::before {
    content: '';
    width: 3px;
    height: 14px;
    background: var(--gold-400);
    border-radius: 2px;
}

.contacts-group-link {
    color: var(--slate-400);
    text-decoration: none;
    cursor: pointer;
}
.contacts-group-link:hover {
    color: var(--navy-500);
    text-decoration: underline;
}


.contact-info-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.04);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.contact-info-card .info-item label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--slate-400);
    font-weight: 600;
    display: block;
    margin-bottom: 3px;
}

.contact-info-card .info-item p {
    font-size: 14px;
    color: var(--slate-800);
    font-weight: 500;
}

/* ===== SENSOR INFO CARD ===== */
.sensor-info-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.04);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.sensor-info-card .info-item label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--slate-400);
    font-weight: 600;
    display: block;
    margin-bottom: 3px;
}

.sensor-info-card .info-item p {
    font-size: 14px;
    color: var(--slate-800);
    font-weight: 500;
}

.field-placeholder {
    color: var(--slate-300);
    font-style: italic;
    font-weight: 400;
}

.editable-field {
    cursor: pointer;
    transition: color 0.15s ease;
    position: relative;
}

.editable-field:hover {
    color: var(--navy-600);
}

.editable-field:hover::before {
    content: '\270E';
    margin-right: 4px;
    font-size: 13px;
    color: var(--slate-400);
    pointer-events: none;
}

.editable-field:hover::after {
    content: 'click to edit';
    position: absolute;
    bottom: -16px;
    left: 0;
    font-size: 10px;
    color: var(--slate-400);
    font-weight: 400;
    font-style: italic;
    white-space: nowrap;
    pointer-events: none;
}

.move-sensor-link {
    display: inline;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--navy-500);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    margin-left: 8px;
}

.move-sensor-link:hover {
    color: var(--navy-400);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ===== FILES GRID ===== */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.file-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.04);
    transition: all 0.25s var(--ease-out);
}

.file-card:hover {
    box-shadow: var(--shadow-md);
}

.file-card-with-thumb {
    display: flex;
    flex-direction: row;
    align-items: center;
}

.file-thumb {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    margin: 12px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--slate-100);
    cursor: pointer;
    transition: transform 0.2s var(--ease-out);
}

.file-thumb:hover {
    transform: scale(1.05);
}

.file-thumb img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    display: block;
    border-radius: 8px;
}

.file-card-with-thumb .file-info {
    border-top: none;
    border-left: 1px solid var(--slate-100);
    flex: 1;
}

.file-card .file-info {
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--slate-100);
}

.file-card .file-name {
    font-size: 13px;
    color: var(--slate-700);
    word-break: break-all;
    font-weight: 500;
}

.file-card .file-date {
    font-size: 11px;
    color: var(--slate-400);
}

.file-card-pdf {
    padding: 48px 20px;
    text-align: center;
    background: linear-gradient(135deg, var(--slate-50), rgba(244, 63, 94, 0.03));
}

.file-card-pdf .pdf-icon {
    font-size: 52px;
    color: var(--aurora-rose);
    filter: drop-shadow(0 2px 4px rgba(244, 63, 94, 0.2));
}

.file-card-pdf .pdf-label {
    font-size: 13px;
    color: var(--slate-500);
    margin-top: 10px;
    font-weight: 500;
}

/* ===== MODALS ===== */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 15, 26, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.open {
    display: flex;
    animation: modalOverlayIn 0.2s var(--ease-out);
}

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

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: modalSlideIn 0.3s var(--ease-spring);
}

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

.modal-content.modal-sm {
    max-width: 420px;
}

.modal-content.modal-lg {
    max-width: 700px;
}

.modal-content.modal-xl {
    max-width: 1000px;
}

/* ===== AUDIT ANALYSIS ===== */
.analysis-instructions {
    background: var(--navy-50, #f0f2f7);
    border: 1px solid var(--navy-100, #d4d9e6);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin: 20px 0 16px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--navy-700, #2a3a5c);
}

.analysis-instructions ol {
    margin: 8px 0 0 16px;
    padding: 0;
}

.analysis-instructions li {
    margin-bottom: 4px;
}

.analysis-upload-zone {
    border: 2px dashed var(--slate-200);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    margin: 16px 0;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.analysis-upload-zone:hover {
    border-color: var(--navy-400);
    background: var(--navy-50, #f0f2f7);
}

.analysis-upload-zone input[type="file"] {
    display: none;
}

.analysis-upload-icon {
    font-size: 32px;
    color: var(--slate-300);
    margin-bottom: 8px;
}

.analysis-upload-text {
    font-size: 14px;
    color: var(--slate-500);
    font-weight: 500;
}

.analysis-upload-hint {
    font-size: 12px;
    color: var(--slate-400);
    margin-top: 4px;
}

.analysis-processing {
    text-align: center;
    padding: 40px 20px;
    color: var(--slate-500);
    font-size: 14px;
}

.analysis-processing:not([style*="color"])::before {
    content: '';
    display: block;
    width: 32px;
    height: 32px;
    margin: 0 auto 12px;
    border: 3px solid var(--slate-200);
    border-top-color: var(--navy-500);
    border-radius: 50%;
    animation: analysisSpinner 0.8s linear infinite;
}

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

.analysis-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--slate-100);
    margin: 20px 0 0;
}

.analysis-tab {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--slate-400);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.analysis-tab:hover {
    color: var(--navy-500);
}

.analysis-tab.active {
    color: var(--navy-700);
    border-bottom-color: var(--gold-500, #C9A84C);
}

.analysis-tab-panel {
    display: none;
    padding: 20px 0;
}

.analysis-tab-panel.active {
    display: block;
}

/* DQO Summary Table */
.dqo-summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.dqo-summary-table th {
    text-align: right;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--slate-400);
    border-bottom: 2px solid var(--slate-100);
    white-space: nowrap;
}

.dqo-summary-table th:first-child { text-align: left; }
.dqo-summary-table th:last-child { text-align: center; }

.dqo-thresh {
    display: block;
    font-size: 10px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: var(--slate-500);
    margin-top: 2px;
}

.dqo-summary-table sub {
    font-size: 0.85em;
    vertical-align: baseline;
    position: relative;
    top: 0.3em;
}

.dqo-summary-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--slate-100);
    font-family: var(--font-mono);
    font-size: 12px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.dqo-summary-table tbody tr:nth-child(even) {
    background: var(--slate-25);
}

.dqo-summary-table td:first-child {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 13px;
    color: var(--slate-700);
    text-align: left;
}

.dqo-summary-table td:last-child {
    text-align: center;
}

.dqo-summary-table tr:last-child td {
    border-bottom: none;
}

.dqo-pass {
    display: inline-block;
    background: #e6f9ed;
    color: #1a7f37;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-sans);
    letter-spacing: 0.3px;
}

.dqo-fail {
    display: inline-block;
    background: #fde8e8;
    color: #c53030;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-sans);
    letter-spacing: 0.3px;
}

.dqo-cell-pass {
    color: #1a7f37;
}

.dqo-cell-fail {
    color: #c53030;
    font-weight: 700;
}

.dqo-overall {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
}

.dqo-overall.pass {
    background: #e6f9ed;
    color: #1a7f37;
    border: 1px solid #a3e4b8;
}

.dqo-overall.fail {
    background: #fde8e8;
    color: #c53030;
    border: 1px solid #f5b3b3;
}

/* Chart Grid */
.analysis-chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 8px;
}

/* ===== COMMUNITY OVERVIEW DASHBOARD ===== */
.community-overview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 8px;
}

.ov-card {
    background: var(--surface);
    border: 1px solid var(--slate-100);
    border-radius: var(--radius-lg);
    padding: 16px;
}

.ov-card-wide {
    grid-column: span 2;
}

.ov-card-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--slate-400);
    margin: 0 0 10px;
}

.ov-sensor-card {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 10px 12px;
    border: 1px solid var(--slate-100);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.15s;
    margin-bottom: 8px;
}

.ov-sensor-card:hover {
    border-color: var(--navy-200);
}

.ov-sensor-left {
    min-width: 110px;
}

.ov-sensor-id {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
    color: var(--slate-700);
    line-height: 1.2;
}

.ov-sensor-type {
    font-size: 11px;
    color: var(--slate-400);
}

.ov-sensor-right {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    align-items: center;
}

.ov-sensor-field {
    font-size: 12px;
    color: var(--slate-500);
}

.ov-timeline-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--slate-50);
    font-size: 13px;
}

.ov-timeline-item:last-of-type {
    border-bottom: none;
}

.ov-timeline-type {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--navy-500);
    background: var(--navy-50);
    padding: 2px 8px;
    border-radius: 8px;
    white-space: nowrap;
}

.ov-timeline-text {
    color: var(--slate-600);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ov-timeline-date {
    font-size: 11px;
    color: var(--slate-400);
    white-space: nowrap;
}

.ov-contact-row {
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
    margin-bottom: 4px;
}

.ov-contact-row:hover {
    background: var(--slate-50);
}

.ov-audit-card {
    padding: 10px;
    border: 1px solid var(--slate-100);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.15s;
}

.ov-audit-card:hover {
    border-color: var(--navy-200);
}

.ov-card-clickable {
    cursor: pointer;
    transition: color 0.15s;
}

.ov-card-clickable:hover {
    color: var(--navy-500);
}

.ov-card-expand {
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.15s;
    margin-left: 4px;
}

.ov-card-clickable:hover .ov-card-expand {
    opacity: 0.6;
}


.ov-empty {
    font-size: 13px;
    color: var(--slate-400);
    margin: 0;
}

@media (max-width: 768px) {
    .community-overview-grid { grid-template-columns: 1fr; }
    .ov-card-wide { grid-column: span 1; }
}


/* ===== ANALYSIS CHARTS ===== */
.analysis-chart-card {
    background: var(--surface);
    border: 1px solid var(--slate-100);
    border-radius: var(--radius-lg);
    padding: 16px;
    position: relative;
    padding-left: 32px;
}

.analysis-chart-card h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--slate-700);
    margin: 0 0 8px;
}

.analysis-chart-card .chart-canvas-wrap {
    position: relative;
    width: 100%;
    height: 260px;
}

/* Scale edit — inline pencil buttons next to axis labels, never overlap canvas */
.chart-scale-btn {
    display: inline-block;
    font-size: 10px;
    color: var(--slate-300);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    margin-left: 4px;
    vertical-align: middle;
}

.analysis-chart-card:hover .chart-scale-btn {
    opacity: 0.6;
}

.chart-scale-btn:hover {
    opacity: 1 !important;
    color: var(--navy-500);
}

.chart-title-editable {
    font-size: 13px;
    font-weight: 600;
    color: var(--slate-700);
    cursor: text;
    border-radius: 4px;
    padding: 2px 4px;
    margin: -2px -4px 0;
    transition: background 0.15s;
}

.chart-title-editable:hover {
    background: var(--slate-50);
}

.chart-subtitle-editable {
    font-size: 11px;
    font-weight: 400;
    color: var(--slate-400);
    cursor: text;
    border-radius: 4px;
    padding: 1px 4px;
    margin: 0 -4px 8px;
    transition: background 0.15s;
}

.chart-subtitle-editable:hover {
    background: var(--slate-50);
}

.chart-axis-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--slate-500);
    cursor: text;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background 0.15s;
}

.chart-axis-label:hover {
    background: var(--slate-50);
}

.chart-axis-y {
    writing-mode: vertical-lr;
    transform: rotate(180deg);
    position: absolute;
    left: 6px;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    text-align: center;
}

.chart-axis-x {
    text-align: center;
    margin-top: 2px;
}

.chart-equation {
    text-align: center;
    font-family: var(--font-sans);
    font-size: 12px;
    color: var(--slate-500);
    margin-top: 4px;
    padding: 4px;
}

.chart-ts-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 6px;
    font-size: 11px;
    color: var(--slate-500);
}

.chart-ts-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chart-ts-legend-item span:first-child {
    display: inline-block;
    width: 14px;
    height: 3px;
    border-radius: 2px;
}


.chart-subtitle-input {
    width: 100%;
    font-size: 11px;
    font-weight: 400;
    font-family: var(--font-sans);
    color: var(--slate-400);
    border: 1px solid var(--slate-200);
    border-radius: 4px;
    padding: 2px 6px;
    outline: none;
    background: var(--surface);
}

.chart-title-input {
    width: 100%;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-sans);
    color: var(--slate-700);
    border: 1px solid var(--navy-400);
    border-radius: 4px;
    padding: 4px 8px;
    outline: none;
    background: var(--surface);
}

.axis-popover {
    position: absolute;
    z-index: 10;
    background: var(--surface);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: 6px 8px;
}

.axis-popover-row {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.axis-popover-row label {
    font-size: 10px;
    font-weight: 600;
    color: var(--slate-400);
    text-transform: uppercase;
}

.axis-popover-row input {
    width: 64px;
    padding: 3px 6px;
    border: 1px solid var(--slate-200);
    border-radius: 4px;
    font-size: 12px;
    font-family: var(--font-mono);
    text-align: center;
}

.axis-popover-row input:focus {
    outline: none;
    border-color: var(--navy-400);
}

.axis-popover-apply {
    background: var(--navy-800);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-sans);
}

.axis-popover-apply:hover {
    background: var(--navy-600);
}

.axis-popover-close {
    background: none;
    border: none;
    color: var(--slate-400);
    font-size: 14px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}

/* Raw Data Table */
.analysis-raw-wrap {
    max-height: 500px;
    overflow: auto;
    border: 1px solid var(--slate-100);
    border-radius: var(--radius-lg);
}

.analysis-raw-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    font-family: var(--font-mono);
    white-space: nowrap;
}

.analysis-raw-table th {
    position: sticky;
    top: 0;
    background: var(--navy-800, #1e2a4a);
    color: white;
    padding: 8px 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    z-index: 1;
}

.analysis-raw-table td {
    padding: 5px 10px;
    border-bottom: 1px solid var(--slate-50);
}

.analysis-raw-table tr:nth-child(even) {
    background: var(--slate-25, #fafbfc);
}

.analysis-raw-table .trimmed-row {
    opacity: 0.4;
    background: #fff8e8;
}

/* Audit cards in community/sensor views */
.audit-list-card {
    background: var(--surface);
    border: 1px solid var(--slate-100);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.audit-list-card:hover {
    border-color: var(--navy-200);
    box-shadow: var(--shadow-sm);
}

.audit-list-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.audit-list-card-sensors {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--slate-500);
    margin-bottom: 6px;
}

.audit-list-card-meta {
    font-size: 12px;
    color: var(--slate-400);
}

.audit-list-card-results {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.audit-param-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 8px;
    font-family: var(--font-sans);
}

.audit-param-badge.pass {
    background: #e6f9ed;
    color: #1a7f37;
}

.audit-param-badge.fail {
    background: #fde8e8;
    color: #c53030;
}

.audit-param-badge.pending {
    background: var(--slate-50);
    color: var(--slate-400);
}

.analysis-name-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font-sans);
    margin: 12px 0;
}

.analysis-name-input:focus {
    outline: none;
    border-color: var(--navy-400);
    box-shadow: 0 0 0 3px rgba(27,42,74,0.1);
}

/* ===== IMAGE LIGHTBOX ===== */
.image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: lbFadeIn 0.15s ease;
}

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

.image-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    cursor: pointer;
}

.image-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    z-index: 1;
}

.image-lightbox-content img {
    display: block;
    max-width: 90vw;
    max-height: 85vh;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    object-fit: contain;
    background: white;
}

.image-lightbox-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: white;
    border: none;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    color: var(--slate-600);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.image-lightbox-close:hover {
    background: var(--slate-100);
}

/* ===== AUDIT PHOTOS ===== */
.audit-photos-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.audit-photo-thumb {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--slate-200);
}

.audit-photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    transition: opacity 0.15s;
}

.audit-photo-thumb img:hover {
    opacity: 0.8;
}

.audit-photo-delete {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
}

.audit-photo-thumb:hover .audit-photo-delete {
    display: flex;
}

.analysis-section-heading {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--slate-400);
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--slate-100);
}

.analysis-trim-note {
    display: inline-block;
    background: #fff8e8;
    color: #8a6d20;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 12px;
}

.analysis-dqo-thresholds {
    font-size: 12px;
    color: var(--slate-500);
    margin-top: 10px;
    padding: 10px 14px;
    background: var(--slate-25, #fafbfc);
    border-radius: var(--radius-sm);
    line-height: 1.5;
}

.analysis-view-btn {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    color: var(--navy-500);
    cursor: pointer;
    margin-top: 8px;
}

.analysis-view-btn:hover {
    text-decoration: underline;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 22px 28px;
    border-bottom: 1px solid var(--slate-100);
}

.modal-header h2 {
    font-size: 17px;
    font-weight: 600;
    color: var(--slate-800);
    letter-spacing: -0.01em;
}

.modal-close {
    background: var(--slate-100);
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--slate-400);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s var(--ease-out);
}

.modal-close:hover {
    color: var(--slate-700);
    background: var(--slate-200);
}

.form-group {
    padding: 0 28px;
    margin-top: 18px;
    position: relative;
}

.form-group label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--slate-500);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.note-action-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--slate-600);
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
    padding: 4px 0;
}
.note-action-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--navy-500);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font-sans);
    color: var(--slate-800);
    background: var(--surface);
    transition: all 0.2s var(--ease-out);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--gold-400);
    box-shadow: 0 0 0 3px rgba(37, 99, 176, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--slate-300);
}

.form-group textarea {
    resize: vertical;
    line-height: 1.6;
}

.status-toggle-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0;
}

.status-toggle-option {
    cursor: pointer;
    opacity: 0.4;
    transition: all 0.15s var(--ease-out);
    border-radius: 100px;
}

.status-toggle-option:hover {
    opacity: 0.7;
}

.status-toggle-option.active {
    opacity: 1;
}

.status-toggle-option .badge {
    pointer-events: none;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 22px 28px;
    border-top: 1px solid var(--slate-100);
    margin-top: 8px;
}

/* ===== MENTION AUTOCOMPLETE ===== */
.mention-dropdown {
    display: none;
    position: absolute;
    background: var(--surface);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1100;
    width: calc(100% - 56px);
    left: 28px;
}

.mention-dropdown.visible {
    display: block;
    animation: dropdownIn 0.15s var(--ease-out);
}

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

.mention-option {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 13.5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.1s ease;
    border-bottom: 1px solid var(--slate-50);
}

.mention-option:last-child {
    border-bottom: none;
}

.mention-option:hover, .mention-option.selected {
    background: rgba(37, 99, 176, 0.06);
}

.mention-option .mention-community {
    font-size: 11.5px;
    color: var(--slate-400);
    font-weight: 500;
}

/* ===== EMAIL COMPOSER ===== */
.email-composer {
    padding: 0;
}

.email-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 28px;
    background: var(--slate-50);
    border-bottom: 1px solid var(--slate-100);
    flex-wrap: wrap;
}

.email-toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.email-toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.email-toolbar-right select {
    min-width: 160px;
}

.email-toolbar-divider {
    color: var(--slate-200);
    margin: 0 4px;
}

.btn-email-list {
    background: var(--gold-500) !important;
    color: var(--navy-900) !important;
    font-weight: 600 !important;
    border: 1px solid var(--gold-400) !important;
    padding: 6px 14px !important;
}

.btn-email-list:hover {
    background: var(--gold-400) !important;
}

.btn-email-list.active {
    outline: 2px solid var(--navy-600);
    outline-offset: 1px;
}

.email-list-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--gold-100);
    color: var(--gold-600);
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 6px;
    vertical-align: middle;
}

.email-bcc-row {
    padding: 10px 28px;
    border-bottom: 1px solid var(--slate-100);
}

.email-bcc-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--slate-700);
}

.email-bcc-toggle input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--navy-600);
    cursor: pointer;
}

.email-bcc-hint {
    font-size: 11.5px;
    font-weight: 400;
    color: var(--slate-400);
}

.email-toolbar-label {
    font-size: 12.5px;
    color: var(--slate-500);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.email-recipients-list {
    padding: 14px 28px;
    max-height: 260px;
    overflow-y: auto;
    border-bottom: 1px solid var(--slate-100);
}

.email-recipient-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
    font-size: 13.5px;
    color: var(--slate-700);
}

.email-recipient-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--navy-600);
    cursor: pointer;
}

.email-recipient-row .recipient-community {
    font-size: 12px;
    color: var(--slate-400);
    margin-left: auto;
    font-family: var(--font-mono);
}

.email-community-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--slate-400);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 12px 0 5px;
    border-bottom: 1px solid var(--slate-100);
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.email-community-header::before {
    content: '';
    width: 3px;
    height: 12px;
    background: var(--gold-400);
    border-radius: 2px;
}

.email-community-header:first-child {
    margin-top: 0;
}

/* ===== LINK-STYLE CLICKABLE ===== */
.clickable {
    color: var(--navy-600);
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s ease;
}

.clickable:hover {
    color: var(--navy-500);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ===== TIMELINE ADDITIONAL INFO ===== */
.timeline-additional-info {
    margin-top: 8px;
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--slate-500);
}

.timeline-additional-info em {
    font-style: italic;
}

/* ===== TAG CHIP INPUTS ===== */
.tag-chip-container {
    position: relative;
}

.tag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    padding: 6px 10px;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    background: var(--surface);
    min-height: 40px;
    cursor: text;
    transition: border-color 0.2s var(--ease-out);
}

.tag-chips:focus-within {
    border-color: var(--navy-400);
    box-shadow: 0 0 0 3px rgba(37, 99, 176, 0.1);
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--navy-100);
    color: var(--navy-700);
    border-radius: 100px;
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
    animation: chipIn 0.15s var(--ease-spring);
}

@keyframes chipIn {
    from { opacity: 0; transform: scale(0.85); }
    to { opacity: 1; transform: scale(1); }
}

.tag-chip-remove {
    cursor: pointer;
    font-size: 14px;
    color: var(--navy-400);
    line-height: 1;
    margin-left: 2px;
    transition: color 0.15s ease;
}

.tag-chip-remove:hover {
    color: var(--aurora-rose);
}

.tag-chip-input {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 2px 4px !important;
    font-size: 13.5px !important;
    flex: 1;
    min-width: 120px;
    background: transparent !important;
}

.tag-chip-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
}

/* ===== LOGIN SCREEN ===== */
/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--surface);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.loading-spinner-container { text-align: center; }
.loading-spinner {
    width: 40px; height: 40px;
    margin: 0 auto 16px;
    border: 3px solid var(--slate-200);
    border-top-color: var(--navy-500);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    color: var(--navy-400);
    letter-spacing: 0.5px;
}

.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(30, 58, 95, 0.06) 0%, transparent 50%),
        var(--slate-100);
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 40px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(0, 0, 0, 0.04);
    width: 380px;
    max-width: 90%;
    text-align: center;
}

.login-card h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--navy-800);
    margin-bottom: 6px;
}

.login-card p {
    font-size: 13px;
    color: var(--slate-400);
    margin-bottom: 24px;
}

.login-field {
    margin-bottom: 10px;
}

.login-field input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font-sans);
}

.login-field input:focus {
    outline: none;
    border-color: var(--navy-400);
    box-shadow: 0 0 0 3px rgba(37, 99, 176, 0.1);
}

.login-toggle {
    font-size: 12.5px;
    color: var(--slate-400);
    text-align: center;
    margin-top: 12px;
}

.login-toggle a {
    color: var(--navy-600);
    text-decoration: none;
    font-weight: 600;
}

.login-toggle a:hover {
    text-decoration: underline;
}

.login-error {
    display: none;
    background: rgba(244, 63, 94, 0.08);
    color: var(--aurora-rose);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 12px;
    text-align: center;
}

.login-error.visible {
    display: block;
}

/* ===== SIDEBAR USER ===== */
.sidebar-user {
    padding: 10px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 12px;
    color: var(--gold-300);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-user .user-name {
    font-weight: 600;
}

.sidebar-user-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-settings-btn {
    font-size: 20px;
    color: var(--slate-300);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 4px;
    border-radius: 4px;
}

.sidebar-settings-btn:hover {
    color: var(--gold-300);
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-user .user-logout {
    font-size: 11px;
    color: var(--slate-400);
    cursor: pointer;
    transition: color 0.15s ease;
}

.sidebar-user .user-logout:hover {
    color: #ffffff;
}

/* ===== CHANGE ATTRIBUTION ===== */
.timeline-attribution {
    font-size: 11.5px;
    color: var(--slate-400);
    font-style: italic;
    margin-top: 6px;
}

/* ===== SETTINGS ===== */
.settings-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.settings-section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--slate-800);
    margin-bottom: 12px;
}

/* MFA Toggle Switch */
.mfa-toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
}
.mfa-toggle-switch input { opacity: 0; width: 0; height: 0; }
.mfa-toggle-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--slate-300);
    border-radius: 24px;
    transition: background 0.2s;
}
.mfa-toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    left: 3px; bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}
.mfa-toggle-switch input:checked + .mfa-toggle-slider { background: #1B2A4A; }
.mfa-toggle-switch input:checked + .mfa-toggle-slider::before { transform: translateX(20px); }

.settings-description {
    font-size: 13px;
    color: var(--slate-400);
    margin-bottom: 16px;
}

.settings-card {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.settings-card .info-item label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--slate-400);
    font-weight: 600;
    display: block;
    margin-bottom: 3px;
}

.settings-card .info-item p {
    font-size: 14px;
    color: var(--slate-800);
    font-weight: 500;
}
.settings-editable-name {
    cursor: pointer;
    border-radius: 6px;
    padding: 2px 6px;
    margin: -2px -6px;
    transition: background 0.15s;
}
.settings-editable-name:hover {
    background: var(--slate-50);
}

.settings-user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--slate-100);
}

.settings-user-row:last-of-type {
    border-bottom: none;
}

.settings-user-email {
    font-size: 14px;
    color: var(--slate-700);
    font-weight: 500;
}

.settings-user-you {
    font-size: 11px;
    color: var(--navy-600);
    font-weight: 600;
    margin-left: 8px;
}

.btn-delete-user {
    background: transparent;
    color: var(--rose-600, #e11d48);
    border: 1px solid var(--rose-200, #fecdd3);
    font-size: 11px;
    font-weight: 600;
}

.btn-delete-user:hover {
    background: var(--rose-50, #fff1f2);
    border-color: var(--rose-400, #fb7185);
}

.mfa-setup-container {
    text-align: center;
    padding: 16px 0;
}

.mfa-qr-code {
    margin: 16px auto;
    padding: 16px;
    background: white;
    border-radius: var(--radius-md);
    display: inline-block;
}

.mfa-verify-field {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 16px;
}

.mfa-verify-field input {
    width: 200px;
    padding: 10px 14px;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-family: var(--font-mono);
    text-align: center;
    letter-spacing: 4px;
}

/* ===== GLOBAL SEARCH ===== */
.global-search-bar {
    padding: 8px 36px;
    background: var(--surface);
    border-bottom: 1px solid var(--slate-100);
    position: relative;
    flex-shrink: 0;
}

.global-search-bar input {
    width: 100%;
    padding: 8px 14px;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: var(--font-sans);
    color: var(--slate-700);
    background: var(--slate-50);
}

.global-search-bar input:focus {
    outline: none;
    border-color: var(--navy-400);
    box-shadow: 0 0 0 3px rgba(37, 99, 176, 0.1);
    background: var(--surface);
}

.global-search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 36px;
    right: 36px;
    background: var(--surface);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    z-index: 900;
}

.global-search-results.visible {
    display: block;
}

.search-result-group {
    padding: 6px 0;
    border-bottom: 1px solid var(--slate-100);
}

.search-result-group:last-child {
    border-bottom: none;
}

.search-result-group-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--slate-400);
    padding: 4px 16px;
}

.search-result-item {
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.1s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-result-item:hover {
    background: rgba(37, 99, 176, 0.04);
}

.search-result-name {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--slate-800);
}

.search-result-meta {
    font-size: 11.5px;
    color: var(--slate-400);
}

/* ===== SORTABLE TABLE HEADERS ===== */
.sortable-th {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s ease;
}

.sortable-th:hover {
    color: var(--navy-600);
}

.sortable-th.sort-active {
    color: var(--navy-600);
}

.sortable-th.sort-active::after {
    content: ' \25B2';
    font-size: 9px;
}

.sortable-th.sort-active.sort-desc::after {
    content: ' \25BC';
}

/* ===== BULK ACTIONS ===== */
.sensor-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--navy-600);
    cursor: pointer;
}

/* ===== BACK BUTTON ===== */
.back-button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
    color: var(--slate-400);
    cursor: pointer;
    margin-bottom: 12px;
    transition: color 0.15s ease;
}

.back-button:hover {
    color: var(--navy-600);
}

/* ===== PINNED SIDEBAR ===== */
.sidebar-pinned-header {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--slate-600);
    padding: 12px 14px 4px;
}

.sidebar-pinned-list {
    list-style: none;
}

.sidebar-pinned-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px 6px 24px;
    color: var(--slate-400);
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 500;
    transition: all 0.15s ease;
    border-radius: var(--radius-sm);
    margin: 0 8px;
}

.sidebar-pinned-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--slate-200);
}

.sidebar-pin-remove {
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.15s ease;
    color: var(--slate-500);
}

.sidebar-pinned-item:hover .sidebar-pin-remove {
    opacity: 1;
}

.sidebar-pin-remove:hover {
    color: var(--aurora-rose);
}

/* ===== COMMUNITY DETAIL HEADER ===== */
.community-detail-header {
    margin-bottom: 20px;
}

.community-detail-top {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.community-detail-top h1 {
    font-size: 22px;
    font-weight: 600;
    color: var(--slate-900);
    letter-spacing: -0.02em;
}

.community-edit-name-btn {
    font-size: 16px;
    color: var(--slate-300);
    cursor: pointer;
    opacity: 0;
    transition: all 0.15s ease;
    padding: 2px 4px;
    border-radius: 4px;
}

.community-detail-top:hover .community-edit-name-btn {
    opacity: 1;
}

.community-edit-name-btn:hover {
    color: var(--navy-600);
    background: rgba(37, 99, 176, 0.06);
}

.community-detail-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ===== COMMUNITY LIST TABS ===== */
.community-list-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--slate-200);
}

.community-list-tab {
    padding: 10px 20px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: all 0.15s;
}

.community-list-tab:hover {
    color: var(--navy-700);
}

.community-list-tab.active {
    color: var(--navy-700);
    border-bottom-color: var(--gold-500);
}

.community-tab-count {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-tertiary);
    margin-left: 4px;
}

.community-list-tab.active .community-tab-count {
    color: var(--navy-500);
}

/* ===== DEACTIVATED COMMUNITIES ===== */
.deactivated-section-header {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--slate-400);
    padding: 20px 0 8px;
    margin-top: 12px;
    border-top: 1px solid var(--slate-200);
}

.community-row-deactivated {
    opacity: 0.5;
    position: relative;
}

.community-row-deactivated:hover {
    opacity: 0.8;
}

.community-delete-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    padding: 4px 6px;
    border-radius: 4px;
    color: var(--slate-400);
}

.community-row-deactivated .community-row-sensors {
    margin-right: 32px;
}

.community-row-deactivated:hover .community-delete-btn {
    opacity: 1;
}

.community-delete-btn:hover {
    color: var(--aurora-rose, #e74c3c);
    background: rgba(231, 76, 60, 0.1);
}

/* ===== IMPORT LINK ===== */
.import-link {
    font-size: 12px;
    color: var(--slate-400);
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s ease;
}

.import-link:hover {
    color: var(--navy-600);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ===== CUSTOM FIELD DELETE ===== */
.delete-field-btn {
    font-size: 14px;
    color: var(--slate-400);
    cursor: pointer;
    margin-left: 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

th:hover .delete-field-btn {
    opacity: 1;
}

.delete-field-btn:hover {
    color: var(--aurora-rose);
}

.field-reorder-btns {
    display: inline-flex;
    gap: 2px;
    margin-left: 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

th:hover .field-reorder-btns {
    opacity: 1;
}

.field-arrow {
    font-size: 10px;
    color: var(--slate-400);
    cursor: pointer;
    padding: 2px;
    border-radius: 3px;
}

.field-arrow:hover {
    color: var(--navy-600);
    background: rgba(37, 99, 176, 0.1);
}

/* ===== EXPORT FIELD SELECTION ===== */
.export-fields-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 0;
}

.export-field-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    color: var(--slate-700);
    cursor: pointer;
    padding: 4px 0;
}

.export-field-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--navy-600);
}

/* ===== SERVICE TICKETS ===== */
/* Sidebar sub-item */
.sidebar-sub-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px 7px 36px;
    color: var(--slate-300);
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 500;
    transition: all 0.15s ease;
    border-radius: var(--radius-sm);
    margin: 2px 8px;
}

.sidebar-sub-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
}

.badge-service-quant { background: rgba(167, 139, 250, 0.12); color: #6d28d9; }
.badge-service-quant::before { background: #8b5cf6; box-shadow: 0 0 6px rgba(139, 92, 246, 0.4); }

.badge-ticket-status { background: rgba(109, 40, 217, 0.08); color: #6d28d9; border: 1.5px dashed rgba(139, 92, 246, 0.5); font-style: italic; }
.badge-ticket-status::before { background: #8b5cf6; box-shadow: 0 0 6px rgba(139, 92, 246, 0.4); }

.service-badge-count { background: var(--aurora-rose); color: white; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; margin-left: auto; }
.btn-service { background: rgba(167, 139, 250, 0.1); color: #6d28d9; border: 1px solid rgba(167, 139, 250, 0.3); }
.btn-service:hover { background: rgba(167, 139, 250, 0.2); }
.service-pipeline { display: flex; flex-direction: column; gap: 16px; }
.service-pipeline-column { background: var(--slate-50); border-radius: var(--radius-md); padding: 14px; }
.service-pipeline-column-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 2px solid var(--slate-200); }
.service-pipeline-column-header h3 { font-size: 12px; font-weight: 600; color: var(--slate-500); text-transform: uppercase; letter-spacing: 0.5px; margin: 0; }
.service-pipeline-count { background: var(--slate-200); color: var(--slate-600); font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; }
.service-ticket-card { background: var(--surface); border-radius: var(--radius-md); padding: 14px 16px; margin-bottom: 8px; box-shadow: var(--shadow-sm); cursor: pointer; transition: box-shadow 0.15s; border-left: 3px solid var(--slate-300); }
.service-ticket-card:hover { box-shadow: var(--shadow-md); }
.service-ticket-card.ticket-type-issue { border-left-color: var(--aurora-rose); }
.service-ticket-card.ticket-type-calibration { border-left-color: var(--aurora-amber); }
.service-ticket-card.ticket-type-issue\+calibration { border-left-color: var(--aurora-violet); }
.ticket-sensor-id { font-family: var(--font-mono); font-size: 13px; font-weight: 500; color: var(--slate-800); }
.ticket-type-label { font-size: 10px; color: var(--slate-400); text-transform: uppercase; letter-spacing: 0.5px; }
.ticket-meta { display: flex; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--slate-500); flex-wrap: wrap; }
.ticket-description { font-size: 13px; color: var(--slate-600); margin-top: 6px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* Ticket step indicators */
.ticket-steps { display: flex; gap: 2px; margin-top: 10px; }
.ticket-steps-detail { margin-top: 0; margin-bottom: 4px; }

.ticket-step { display: flex; flex-direction: column; align-items: center; flex: 1; gap: 4px; }
.ticket-step-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--slate-200); transition: all 0.15s ease; }
.ticket-step-label { font-size: 9px; color: var(--slate-500); text-align: center; line-height: 1.2; }

.ticket-step.completed .ticket-step-dot { background: var(--navy-500); }
.ticket-step.completed .ticket-step-label { color: var(--navy-600); font-weight: 600; }
.ticket-step.current .ticket-step-dot { background: var(--aurora-green); box-shadow: 0 0 6px rgba(34, 197, 94, 0.5); }
.ticket-step.current .ticket-step-label { color: var(--aurora-green); font-weight: 700; }
.ticket-step.pending .ticket-step-dot { background: var(--slate-200); }
.ticket-step.pending .ticket-step-label { color: var(--slate-300); }

.ticket-steps-detail .ticket-step-label { font-size: 11px; }
.ticket-steps-detail .ticket-step-dot { width: 12px; height: 12px; }
.ticket-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 20px 28px; }
.ticket-field { display: flex; flex-direction: column; gap: 4px; }
.ticket-field label { font-size: 11px; font-weight: 600; color: var(--slate-500); text-transform: uppercase; letter-spacing: 0.5px; }
.ticket-field p { font-size: 14px; color: var(--slate-800); margin: 0; }
.ticket-field.full-width { grid-column: 1 / -1; }
.ticket-detail-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 28px;
    border-top: 1px solid var(--slate-100);
    flex-wrap: wrap;
}

.ticket-detail-actions .btn { font-size: 13px; }
.ticket-detail-actions .action-spacer { flex: 1; }
.ticket-detail-actions .action-secondary {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}
.ticket-status-badge { display: inline-block; font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 12px; }
.ticket-status-badge.ts-opened { background: rgba(59, 130, 246, 0.1); color: #2563eb; }
.ticket-status-badge.ts-rma { background: rgba(167, 139, 250, 0.1); color: #6d28d9; }
.ticket-status-badge.ts-shipped-to { background: rgba(245, 158, 11, 0.1); color: #d97706; }
.ticket-status-badge.ts-at-quant { background: rgba(244, 63, 94, 0.1); color: #e11d48; }
.ticket-status-badge.ts-shipped-from { background: rgba(245, 158, 11, 0.1); color: #d97706; }
.ticket-status-badge.ts-received { background: rgba(34, 197, 94, 0.1); color: #15803d; }
.ticket-status-badge.ts-closed { background: var(--slate-100); color: var(--slate-500); }
.ticket-edit-input { font-size: 14px; padding: 6px 10px; border: 1px solid transparent; border-radius: var(--radius-sm); width: 100%; font-family: var(--font-sans); background: transparent; transition: border-color 0.15s, background 0.15s; }
.ticket-edit-input:hover { border-color: var(--slate-200); background: var(--surface); }
.ticket-edit-input:focus { border-color: var(--navy-500); background: var(--surface); outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 176, 0.1); }

/* ===== TRACKING LINK ===== */
.tracking-link {
    color: var(--navy-500);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
}

.tracking-link:hover {
    text-decoration: underline;
}

/* ===== UNDO LINK ===== */
.undo-link {
    font-size: 12px;
    color: var(--slate-400);
    cursor: pointer;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background 0.15s, color 0.15s;
}

.undo-link:hover {
    color: var(--slate-600);
    background: var(--slate-50);
}

/* ===== AUDITS ===== */
.audit-pipeline { display: flex; flex-direction: column; gap: 16px; }
.audit-pipeline-column { background: var(--slate-50); border-radius: var(--radius-md); padding: 14px; }
.audit-pipeline-column-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 2px solid var(--slate-200); }
.audit-pipeline-column-header h3 { font-size: 12px; font-weight: 600; color: var(--slate-500); text-transform: uppercase; letter-spacing: 0.5px; margin: 0; }
.audit-pipeline-count { background: var(--slate-200); color: var(--slate-600); font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; }
.audit-card { background: var(--surface); border-radius: var(--radius-md); padding: 14px 16px; margin-bottom: 8px; box-shadow: var(--shadow-sm); cursor: pointer; transition: box-shadow 0.15s; border-left: 3px solid var(--navy-400); }
.audit-card:hover { box-shadow: var(--shadow-md); }
.audit-community-name { font-size: 14px; font-weight: 600; color: var(--slate-800); }
.audit-card-sensors { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.audit-status-badge { display: inline-block; font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 12px; }
.audit-status-badge.as-scheduled { background: rgba(59, 130, 246, 0.1); color: #2563eb; }
.audit-status-badge.as-in-progress { background: rgba(245, 158, 11, 0.1); color: #d97706; }
.audit-status-badge.as-complete { background: rgba(34, 197, 94, 0.1); color: #15803d; }
.audit-status-badge.as-analysis { background: rgba(167, 139, 250, 0.1); color: #6d28d9; }
.audit-status-badge.as-verified { background: rgba(37, 99, 176, 0.1); color: var(--navy-600); }
.audit-status-badge.cs-in-progress { background: rgba(245, 158, 11, 0.1); color: #d97706; }
.audit-status-badge.cs-complete { background: rgba(34, 197, 94, 0.1); color: #15803d; }
.audit-status-badge.cs-analysis { background: rgba(167, 139, 250, 0.1); color: #6d28d9; }
.audit-status-badge.cs-verified { background: rgba(37, 99, 176, 0.1); color: var(--navy-600); }

/* Collocation Analysis Report Styles */
.colloc-report-view { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; color: #1a1a2e; }
.colloc-title-block { text-align: center; margin-bottom: 35px; }
.colloc-title-label { font-size: 14px; font-weight: 400; color: #888; margin-bottom: 2px; letter-spacing: 0.5px; }
.colloc-title-main { font-size: 20px; font-weight: 700; color: #0a1628; margin: 4px 0; }
.colloc-title-dates { font-size: 14px; font-weight: 400; color: #888; }
.colloc-section-header { text-align: center; margin: 50px 0 8px; padding-bottom: 8px; border-bottom: 2px solid #0a1628; }
.colloc-section-header h2 { font-size: 21px; color: #0a1628; }
.colloc-plot-title { text-align: center; margin: 20px 0 2px; }
.colloc-plot-title h3 { font-size: 15px; font-weight: 600; color: #0a1628; }
.colloc-plot-subtitle { text-align: center; font-size: 11.5px; color: #888; margin-bottom: 6px; }
.colloc-reg-param-title { text-align: center; font-size: 14px; font-weight: 600; color: #0a1628; margin: 18px 0 4px; }
.colloc-nav-tabs { display: flex; list-style: none; border-bottom: 2px solid #ddd; padding: 0; margin: 0; gap: 2px; }
.colloc-nav-tabs li { margin: 0; }
.colloc-nav-link { display: block; padding: 9px 22px; font-size: 13px; font-weight: 600; color: #667; text-decoration: none; border: 1px solid transparent; border-bottom: none; border-radius: 6px 6px 0 0; cursor: pointer; background: transparent; font-family: inherit; transition: all 0.15s; }
.colloc-nav-link:hover { color: #0a1628; background: #eee; }
.colloc-nav-link.active { color: #0a1628; background: #fff; border-color: #ddd; border-bottom: 2px solid #fff; margin-bottom: -2px; }
.colloc-tab-content > .colloc-tab-pane { display: none; }
.colloc-tab-content > .colloc-tab-pane.active { display: block; }
.colloc-report-view .data-table-wrap { overflow: auto; max-height: 70vh; border: 1px solid #ccc; border-radius: 6px; margin-top: 10px; }
.colloc-report-view table { border-collapse: collapse; font-size: 11px; white-space: nowrap; }
.colloc-report-view thead th { background: #0a1628; color: #c8a84e; padding: 7px 9px; position: sticky; top: 0; z-index: 10; font-weight: 600; border-right: 1px solid #1a2a40; }
.colloc-report-view tbody td { padding: 3px 9px; border-bottom: 1px solid #eee; border-right: 1px solid #f0f0f0; text-align: right; }
.colloc-report-view tbody td:first-child { text-align: left; font-weight: 500; }
.colloc-report-view tbody tr:hover td { background: #f0f0e8; }
.colloc-report-view tbody td.red { background: #ffe0e0; border: 2px solid #e53e3e; }

.audit-unaudited-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-top: 8px; }
.audit-unaudited-card { background: var(--surface); border: 1px dashed var(--slate-300); border-radius: var(--radius-md); padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--slate-600); cursor: pointer; transition: border-color 0.15s; }
.audit-unaudited-card:hover { border-color: var(--navy-400); }
.analysis-results-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.analysis-results-table th { text-align: left; font-size: 11px; font-weight: 600; color: var(--slate-400); text-transform: uppercase; letter-spacing: 0.5px; padding: 6px 10px; border-bottom: 2px solid var(--slate-200); }
.analysis-results-table td { padding: 6px 10px; border-bottom: 1px solid var(--slate-100); color: var(--slate-700); font-family: var(--font-mono); }

/* ===== SAVE ERROR TOAST ===== */
.save-error-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--aurora-rose);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    animation: toastIn 0.3s var(--ease-out);
}

.save-success-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--navy-800);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    animation: toastIn 0.3s var(--ease-out);
}

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

/* ===== EMPTY STATES ===== */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--slate-400);
    font-size: 14px;
    font-weight: 500;
}

/* ===== PRINT STYLES ===== */
@media print {
    #sidebar, .mobile-header, .sidebar-overlay, .global-search-bar,
    .open-tabs-bar, .back-button, .setup-mode-toggle,
    .btn, button, .history-actions, .filter-bar, .sidebar-bottom-actions,
    .community-detail-toolbar, .timeline-actions, .no-print {
        display: none !important;
    }
    #main-wrapper { margin: 0; }
    #main-content { padding: 20px; }
    body { overflow: visible; height: auto; }
    .view { display: block !important; }
    .view:not(.active) { display: none !important; }
    .table-container { box-shadow: none; border: 1px solid #ddd; }
    .map-iframe-full { display: none; }
    .dashboard-summary { break-inside: avoid; }
    .modal.open { position: static !important; display: block !important; background: none !important; }
    .modal:not(.open) { display: none !important; }
    .modal-content { max-width: 100% !important; box-shadow: none !important; border: none !important; max-height: none !important; overflow: visible !important; }
    .modal-close { display: none !important; }
    .dqo-summary-table, .analysis-chart-card, .timeline-item { break-inside: avoid; page-break-inside: avoid; }
    .report-section { break-inside: avoid; page-break-inside: avoid; }
    .analysis-section-heading { break-after: avoid; page-break-after: avoid; }
    .analysis-chart-grid { break-before: avoid; page-break-before: avoid; }
    #analysis-section-dqo, #analysis-section-timeseries, #analysis-section-scatter { break-inside: avoid; page-break-inside: avoid; }
    .dqo-overall, .dqo-pass, .dqo-fail, .audit-param-badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    @page { margin: 0.5in; }
}

/* ===== CONFIRM / ALERT MODAL ===== */
.modal-confirm-body {
    padding: 16px 28px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--slate-700);
}

#modal-confirm .modal-footer {
    padding: 12px 28px 20px;
}

#modal-confirm .btn-confirm-danger {
    background: linear-gradient(135deg, #e11d48, #be123c);
    color: #fff;
    border: none;
    box-shadow: 0 1px 3px rgba(225, 29, 72, 0.3);
}

#modal-confirm .btn-confirm-danger:hover {
    background: linear-gradient(135deg, #f43f5e, #e11d48);
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.3);
    transform: translateY(-1px);
}
