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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.header h1 { font-size: 20px; white-space: nowrap; }

@media (min-width: 600px) {
    .header { padding: 30px; }
    .header h1 { font-size: 28px; }
}

.logout-btn {
    background: rgba(255,255,255,0.2);
    border: 2px solid white;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.3s;
}

.logout-btn:hover { background: white; color: #667eea; }

.content { padding: 16px; }

@media (min-width: 600px) {
    .content { padding: 30px; }
}

/* Flash messages */
.flash-success {
    background: #d4edda;
    color: #155724;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.flash-error {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

@media (min-width: 600px) {
    .form-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 20px;
    }
}

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

.form-group label {
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s;
    background: white;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

/* Custom multiselect dropdown */
.multiselect { position: relative; }

.multiselect-toggle {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    text-align: left;
    transition: border-color 0.3s;
    color: #333;
}

.multiselect-toggle:focus { outline: none; border-color: #667eea; }

.multiselect-arrow { font-size: 11px; color: #999; flex-shrink: 0; }

.multiselect-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #667eea;
    border-radius: 8px;
    z-index: 200;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    overflow: hidden;
}

.multiselect-dropdown.open { display: block; }

.multiselect-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    font-size: 14px;
    cursor: pointer;
    font-weight: normal;
    color: #333;
    margin: 0;
}

.multiselect-option:hover { background: #f0f0ff; }

.multiselect-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #667eea;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    border: none;
}

.form-group textarea { resize: vertical; min-height: 100px; }

.form-group.full-width { grid-column: 1 / -1; }

.submit-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 40px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: transform 0.2s;
}

.submit-btn:hover { transform: translateY(-2px); }

/* Autocomplete dropdown */
.autocomplete-wrapper { position: relative; width: 100%; }
.autocomplete-wrapper input { width: 100%; }

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #667eea;
    border-top: none;
    border-radius: 0 0 8px 8px;
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 14px;
}

.autocomplete-item:hover { background: #f0f0ff; }

.autocomplete-item--manual { color: #5a6acf; font-style: italic; border-top: 1px solid #eee; font-weight: 500; }
.autocomplete-item--manual:hover { background: #f0f0ff; text-decoration: underline; }

/* Filters */
.filter-toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.filter-toggle-btn {
    background: #f0f0ff;
    border: 1px solid #667eea;
    color: #667eea;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    line-height: 0;
}

.filter-toggle-btn:hover { background: #e0e0ff; }

.filter-active-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #764ba2;
    display: none;
    flex-shrink: 0;
}

.filter-active-dot.visible { display: inline-block; }

/* Search bar in top row */
.search-bar-wrapper {
    flex: 1;
    position: relative;
    min-width: 0;
}

.search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
    pointer-events: none;
}

.search-bar-input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    transition: border-color 0.2s;
    color: #333;
}

.search-bar-input:focus {
    outline: none;
    border-color: #667eea;
}

.filter-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: none;
}

.filter-section.open { display: block; }

.filter-actions { display: flex; gap: 10px; margin-top: 15px; flex-wrap: wrap; }

.search-btn {
    background: #667eea;
    color: white;
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.clear-btn {
    background: #6c757d;
    color: white;
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
}

/* Table */
.activities-table { width: 100%; border-collapse: collapse; }

.activities-table th {
    background: #f8f9fa;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #e0e0e0;
}

.activities-table td {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: top;
}

.activities-table tr:hover td { background: #fafafa; }

/* Delete button — icon style */
.delete-btn {
    background: none;
    border: none;
    color: #bbb;
    padding: 4px;
    cursor: pointer;
    line-height: 0;
    border-radius: 4px;
    transition: color 0.2s;
}

.delete-btn:hover { color: #dc3545; }

/* Card layout on mobile */
@media (max-width: 700px) {
    .activities-table thead { display: none; }

    .activities-table tbody tr {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto auto;
        background: #fff;
        border: 1px solid #e8e8e8;
        border-radius: 12px;
        margin-bottom: 10px;
        padding: 14px 14px 12px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.06);
        gap: 0;
    }

    /* Date — small, muted, top-left */
    .activities-table td[data-label="Date"] {
        grid-column: 1;
        grid-row: 1;
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: #999;
        padding: 0 0 4px 0;
        border: none;
        white-space: nowrap;
    }

    /* Delete icon — top-right, spans rows */
    .activities-table .delete-cell {
        grid-column: 2;
        grid-row: 1 / 4;
        display: flex;
        align-items: flex-start;
        justify-content: flex-end;
        padding: 0 0 0 8px;
        border: none;
    }

    /* Address — prominent, large */
    .activities-table td[data-label="Address"] {
        grid-column: 1;
        grid-row: 2;
        font-size: 15px;
        font-weight: 600;
        color: #1a1a2e;
        padding: 0 0 4px 0;
        border: none;
        line-height: 1.3;
    }

    /* Logged by — small secondary line */
    .activities-table td[data-label="Logged by"] {
        grid-column: 1;
        grid-row: 3;
        font-size: 12px;
        color: #888;
        padding: 0 0 6px 0;
        border: none;
    }

    /* Note — full width below the grid */
    .activities-table td[data-label="Note"] {
        grid-column: 1 / 3;
        grid-row: 4;
        font-size: 13px;
        color: #444;
        line-height: 1.55;
        padding: 8px 0 0 0;
        border-top: 1px solid #f0f0f0;
        border-bottom: none;
        margin-top: 4px;
    }

    /* Hide all ::before labels */
    .activities-table td[data-label]::before { display: none; }
}

.no-results {
    text-align: center;
    color: #999;
    padding: 40px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.pagination a, .pagination span {
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 14px;
    text-decoration: none;
    border: 1px solid #e0e0e0;
    color: #333;
}

.pagination a:hover { background: #f0f0ff; border-color: #667eea; }
.pagination .current { background: #667eea; color: white; border-color: #667eea; }
.pagination .disabled { color: #ccc; pointer-events: none; }

/* Section title */
.section-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.export-btn {
    background: #28a745;
    color: white;
    padding: 8px 10px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    line-height: 0;
}

.export-btn:hover { background: #218838; }
