:root {
    --primary-color: #2c3e50;
    --accent-color: #3498db;
    --danger-color: #e74c3c;
    --success-color: #2ecc71;
    --bg-color: #ecf0f1;
    --card-bg: #ffffff;
    --text-color: #333;
    --border-color: #eee;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
}

/* Navbar */
.navbar {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    /* Allow wrapping on mobile */
}

.navbar h1 {
    margin: 0;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar a {
    color: white;
    text-decoration: none;
    margin-left: 20px;
    transition: opacity 0.2s;
}

.navbar a:hover {
    opacity: 0.8;
}

.nav-links {
    display: flex;
    align-items: center;
}

/* Search Container */
.search-container {
    position: relative;
    margin: 0 20px;
}

.search-input {
    padding: 8px 15px;
    border-radius: 20px;
    border: none;
    width: 300px;
    outline: none;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: none;
    z-index: 1000;
}

.search-results a {
    display: block;
    padding: 10px;
    color: #333;
    border-bottom: 1px solid #eee;
    margin: 0;
    text-decoration: none;
    margin-left: 0;
    /* Override navbar a margin */
}

.search-results a:hover {
    background-color: #f9f9f9;
    color: var(--accent-color);
}

/* Layout */
.container {
    max-width: 1400px;
    margin: 20px auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: 1fr 3fr;
    gap: 20px;
}

/* Dashboard Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stat-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    text-align: center;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    margin: 10px 0;
}

.stat-label {
    color: #7f8c8d;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Main Content & Panels */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.panel-header {
    background-color: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

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

th,
td {
    padding: 15px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: #fdfdfd;
    color: #7f8c8d;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

tr:hover {
    background-color: #f8f9fa;
}

/* Badges */
.status-badge {
    padding: 5px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
    white-space: nowrap;
}

.badge-active {
    background-color: #ffebee;
    color: var(--danger-color);
}

.badge-resolved {
    background-color: #e8f5e9;
    color: var(--success-color);
}

/* Typography Helpers */
.timestamp {
    color: #95a5a6;
    font-size: 0.85rem;
    white-space: nowrap;
}

.danger {
    color: var(--danger-color);
}

.info {
    color: var(--accent-color);
}

/* Buttons */
.btn,
button {
    padding: 8px 16px;
    background-color: var(--accent-color);
    color: white;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
    display: inline-block;
}

.btn:hover,
button:hover {
    background-color: #2980b9;
}

/* Specific Page Styles (Merged) */

/* Login / Setup Cards */
.login-card,
.setup-card,
.form-box,
.card {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
}

.login-card,
.setup-card {
    max-width: 450px;
    margin: 20px auto;
    text-align: center;
}

.card-container-center {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

/* Forms */
input,
select,
textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #dcdde1;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 16px;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent-color);
    outline: none;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #34495e;
}

.error {
    color: var(--danger-color);
    background: #fadbd8;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 20px;
    text-align: center;
}

.info-box {
    background: #e8f8f5;
    border-left: 4px solid #1abc9c;
    padding: 15px;
    margin-bottom: 25px;
    font-size: 14px;
    color: #16a085;
    text-align: left;
}

/* Admin Users */
.role-admin {
    color: #d35400;
    font-weight: bold;
}

.role-operator {
    color: #27ae60;
}

.btn-delete {
    color: var(--danger-color);
    text-decoration: none;
    font-weight: bold;
}

.btn-delete:hover {
    text-decoration: underline;
}

.form-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.form-row input,
.form-row select {
    flex: 1;
}

/* Responsive Media Queries */
@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
        /* Stack sidebar and main content */
    }

    .navbar {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .navbar h1 {
        justify-content: center;
    }

    .nav-links {
        justify-content: center;
        flex-wrap: wrap;
        gap: 10px;
    }

    .navbar a {
        margin-left: 10px;
        margin-right: 10px;
    }

    .search-input {
        width: 100%;
        /* Full width search on mobile */
    }

    .search-container {
        margin: 10px 0;
        width: 100%;
    }

    .form-row {
        flex-direction: column;
    }

    .panel-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    /* Make buttons full width on very small screens if needed, or keeping them inline */

    .login-card,
    .setup-card {
        padding: 20px;
    }

    /* Mobile Table Card View */
    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    /* Hide list headers */
    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        margin-bottom: 1rem;
        background: white;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }

    td {
        border: none;
        border-bottom: 1px solid #eee;
        position: relative;
        padding-left: 50% !important;
        text-align: right;
        min-height: 25px;
        /* Ensure empty cells have height */
    }

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

    td::before {
        position: absolute;
        top: 15px;
        /* Match standard padding */
        left: 15px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
        content: attr(data-label);
        color: #7f8c8d;
    }

    /* Navbar Mobile Styles */
    .navbar {
        flex-direction: column;
        align-items: stretch;
        padding: 10px;
    }

    .navbar-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .hamburger {
        display: block;
        background: none;
        border: none;
        color: white;
        font-size: 1.5rem;
        cursor: pointer;
        padding: 5px;
    }

    .nav-group {
        width: 100%;
    }

    .nav-persistent {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        margin-top: 10px;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        padding-top: 10px;
    }

    .nav-collapsible {
        display: none;
        flex-direction: column;
        gap: 10px;
        width: 100%;
        margin-top: 10px;
        background-color: rgba(0, 0, 0, 0.1);
        padding: 10px;
        border-radius: 4px;
    }

    .nav-collapsible.show {
        display: flex;
    }

    .nav-collapsible a {
        margin: 0;
        padding: 10px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        display: block;
        text-align: center;
    }

    .nav-collapsible .search-container {
        margin: 0;
        width: 100%;
    }

    .nav-collapsible .search-input {
        width: 100%;
    }
}

/* Default Desktop Styles for new navbar classes */
.navbar-header h1 {
    display: flex;
    align-items: center;
}

/* On Desktop, we want these to flow normally */
@media (min-width: 769px) {
    .hamburger {
        display: none;
    }

    .nav-group {
        display: flex;
        align-items: center;
        flex: 1;
        justify-content: flex-end;
    }

    .nav-group .search-container {
        margin-right: auto;
    }

    .nav-persistent {
        margin-right: 15px;
    }

    .nav-persistent,
    .nav-collapsible {
        display: flex;
        /* Ensure they are visible on desktop */
        align-items: center;
    }
}

/* Client List */
.client-list {
    list-style: none;
    padding: 0;
}

.client-list li {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
}

.client-list li:last-child {
    border-bottom: none;
}

.client-list a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: bold;
    display: block;
}

.client-list a:hover {
    color: var(--accent-color);
}

/* --- Filter Buttons --- */
.filter-buttons {
    display: flex;
    gap: 5px;
}

.btn-filter {
    padding: 5px 10px;
    background-color: #ecf0f1;
    color: #7f8c8d;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.8rem;
    border: 1px solid #bdc3c7;
    transition: all 0.2s;
}

.btn-filter:hover {
    background-color: #bdc3c7;
    color: #2c3e50;
}

.btn-filter.active {
    background-color: #3498db;
    color: white;
    border-color: #2980b9;
}