/* PhenomeStudio Global Styles */

/* Reset and Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    padding-top: 70px; /* Account for fixed header */
}

/* Header Navigation */
.header-nav {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-nav .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 70px;
}

.nav-brand h2 {
    margin: 0;
    font-size: 1.5em;
    font-weight: 600;
}

.nav-brand a {
    color: white;
    text-decoration: none;
}

.nav-brand a:hover {
    color: #e6f3ff;
}

.nav-menu {
    display: flex;
    gap: 0;
}

.nav-menu a {
    color: white;
    text-decoration: none;
    padding: 25px 20px;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    font-weight: 500;
}

.nav-menu a:hover {
    background-color: rgba(255,255,255,0.1);
    border-bottom-color: #28a745;
}

.nav-menu a.active {
    background-color: rgba(255,255,255,0.2);
    border-bottom-color: #28a745;
}

.nav-menu a.nav-admin {
    color: #ffc107;
}

.nav-menu a.nav-admin:hover {
    color: #fff;
    background-color: rgba(255,193,7,0.15);
    border-bottom-color: #ffc107;
}

.nav-menu a.nav-admin.active {
    background-color: rgba(255,193,7,0.2);
    border-bottom-color: #ffc107;
}

.nav-badge {
    position: absolute;
    top: 2px;
    right: -8px;
    background: #dc3545;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1;
    padding: 2px 5px;
    border-radius: 999px;
    pointer-events: none;
}

/* ── Admin Pages ───────────────────────────────────────────── */

.admin-header {
    padding: 30px 0 24px;
    border-bottom: 1px solid #e9ecef;
    margin-bottom: 28px;
}

.admin-nav {
    display: flex;
    gap: 12px;
    margin-bottom: 28px;
}

.admin-nav-btn {
    padding: 10px 20px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    text-decoration: none;
    color: #495057;
    font-weight: 500;
    transition: all 0.2s;
}

.admin-nav-btn:hover {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.admin-stat-body {
    padding: 20px;
}

.panel-body {
    padding: 0 20px 20px;
}

.admin-table th,
.admin-table td {
    vertical-align: middle;
}

.role-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.role-select {
    padding: 5px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.9em;
    color: #495057;
}

.action-cell {
    display: flex;
    gap: 6px;
    align-items: center;
}

.add-room-form {
    padding: 20px;
}

.form-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 180px;
    margin-bottom: 0;
}

.form-group-action {
    flex: 0 0 auto;
}

.required {
    color: #dc3545;
}

.panel-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-input {
    padding: 5px 12px;
    border: 1px solid #ced4da;
    border-radius: 20px;
    font-size: 0.875em;
    color: #495057;
    width: 200px;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.search-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.15);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.9em;
}

.nav-user span {
    color: #e6f3ff;
}

/* ── User dropdown in navbar ────────────────────────────────────── */
.nav-user-dropdown {
    position: relative;
}

.nav-user-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #e6f3ff;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    border: none;
    background: none;
    font-size: 0.9em;
    font-weight: 500;
    transition: background 0.2s;
    white-space: nowrap;
}

.nav-user-toggle:hover {
    background: rgba(255,255,255,0.15);
}

.nav-user-toggle .caret {
    font-size: 0.7em;
    opacity: 0.75;
    transition: transform 0.2s;
}

.nav-user-dropdown.open .caret {
    transform: rotate(180deg);
}

.nav-user-dropdown .dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 180px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    z-index: 2000;
    overflow: hidden;
    padding: 4px 0;
}

.nav-user-dropdown.open .dropdown-menu {
    display: block;
}

.dropdown-menu a,
.dropdown-menu button {
    display: block;
    width: 100%;
    padding: 10px 16px;
    text-decoration: none;
    color: #333;
    font-size: 0.9em;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.dropdown-menu a:hover,
.dropdown-menu button:hover {
    background: #f0f4ff;
    color: #007bff;
}

.dropdown-divider {
    height: 1px;
    background: #e9ecef;
    margin: 4px 0;
}

.dropdown-role {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    font-size: 0.78em;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #6c757d;
    cursor: default;
    user-select: none;
}

.dropdown-badge {
    display: inline-block;
    background: #dc3545;
    color: #fff;
    border-radius: 10px;
    font-size: 0.72em;
    font-weight: 700;
    padding: 1px 6px;
    margin-left: 6px;
    vertical-align: middle;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85em;
}

/* Alert close button */
.alert {
    position: relative;
    padding-right: 40px;
}

.alert-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
}

.alert-close:hover {
    opacity: 1;
}

/* Footer */
.footer {
    background-color: #343a40;
    color: white;
    padding: 20px 0;
    margin-top: 50px;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-links {
    display: flex;
    gap: 20px;
}

.footer-links a {
    color: #adb5bd;
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: white;
}

/* Container and Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.main-content {
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

/* Header Styles */
.header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 2px solid #007bff;
    padding-bottom: 20px;
}

.header h1 {
    color: #333;
    margin: 0;
    font-size: 2.5em;
    font-weight: 300;
}

.header p {
    color: #666;
    margin-top: 10px;
    font-size: 1.1em;
}

/* Navigation */
.nav-links {
    text-align: center;
    margin: 30px 0;
}

.nav-links a {
    display: inline-block;
    margin: 5px 10px;
    padding: 12px 24px;
    background-color: #007bff;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-links a:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.nav-links a.active {
    background-color: #28a745;
}

/* Grid Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

/* Card Components */
.card {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 24px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.card h3 {
    margin-top: 0;
    margin-bottom: 16px;
    color: #495057;
    border-bottom: 2px solid #007bff;
    padding-bottom: 8px;
    font-size: 1.3em;
    font-weight: 600;
}

.card h4 {
    color: #6c757d;
    margin-bottom: 12px;
    font-size: 1.1em;
}

/* Status Indicators */
.status {
    padding: 8px 16px;
    border-radius: 20px;
    color: white;
    font-weight: bold;
    text-align: center;
    margin: 10px 0;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status.active {
    background: linear-gradient(135deg, #28a745, #20c997);
}

.status.inactive {
    background: linear-gradient(135deg, #6c757d, #495057);
}

.status.warning {
    background: linear-gradient(135deg, #ffc107, #fd7e14);
}

.status.danger {
    background: linear-gradient(135deg, #dc3545, #e83e8c);
}

/* Metrics */
.metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 12px 0;
    padding: 8px 0;
    border-bottom: 1px solid #f8f9fa;
}

.metric:last-child {
    border-bottom: none;
}

.metric-label {
    font-weight: 500;
    color: #495057;
    font-size: 0.95em;
}

.metric-value {
    color: #007bff;
    font-weight: 700;
    font-size: 1.1em;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #495057;
}

.form-control {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    margin: 5px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    transition: all 0.3s ease;
}

.btn-primary {
    background-color: #007bff;
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}

.btn-success {
    background-color: #28a745;
    color: white;
}

.btn-success:hover {
    background-color: #218838;
}

.btn-warning {
    background-color: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background-color: #e0a800;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

.table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.5px;
}

.table tbody tr:hover {
    background-color: #f8f9fa;
}

/* Alerts */
.alert {
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    border-radius: 4px;
}

.alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.alert-warning {
    color: #856404;
    background-color: #fff3cd;
    border-color: #ffeaa7;
}

.alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

.alert-info {
    color: #0c5460;
    background-color: #d1ecf1;
    border-color: #bee5eb;
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 3rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 3rem; }

.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.p-5 { padding: 3rem; }

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .main-content {
        padding: 20px;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .header h1 {
        font-size: 2em;
    }
    
    .nav-links a {
        display: block;
        margin: 5px 0;
    }
    
    .card {
        padding: 16px;
    }
    
    .metric {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.8em;
    }
    
    .card h3 {
        font-size: 1.1em;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }
}

/* ── Dashboard Page ────────────────────────────────────────── */

.dashboard-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 30px 0 24px;
    border-bottom: 1px solid #e9ecef;
    margin-bottom: 28px;
}

.dashboard-title {
    font-size: 2em;
    font-weight: 600;
    color: #212529;
    margin: 0;
}

.dashboard-subtitle {
    color: #6c757d;
    margin: 4px 0 0;
    font-size: 0.95em;
}

/* Two-column panels */
.dashboard-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

.panel {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid #f0f0f0;
}

.panel-title {
    font-size: 1.1em;
    font-weight: 600;
    color: #343a40;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-badge {
    background: #e9ecef;
    color: #495057;
    border-radius: 12px;
    padding: 2px 10px;
    font-size: 0.8em;
    font-weight: 600;
}

.panel-empty {
    padding: 32px 20px;
    text-align: center;
    color: #adb5bd;
    font-size: 0.9em;
}

/* Rooms */
.room-list {
    padding: 8px 0;
}

.room-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid #f8f9fa;
    transition: background 0.15s;
}

.room-item:last-child {
    border-bottom: none;
}

.room-item:hover {
    background: #f8f9fa;
}

.room-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.room-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #28a745;
    flex-shrink: 0;
}

.room-name {
    font-weight: 600;
    color: #212529;
    white-space: nowrap;
}

.room-desc {
    color: #6c757d;
    font-size: 0.85em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.subject-count {
    font-size: 1.2em;
    font-weight: 700;
    color: #007bff;
    white-space: nowrap;
    margin-left: 12px;
}

.subject-label {
    font-size: 0.65em;
    font-weight: 500;
    color: #6c757d;
    margin-left: 3px;
}

/* Projects */
.project-list {
    list-style: none;
    padding: 8px 0;
    margin: 0;
}

.project-item {
    padding: 14px 20px;
    border-bottom: 1px solid #f8f9fa;
    transition: background 0.15s;
    cursor: pointer;
}

.project-item:last-child {
    border-bottom: none;
}

.project-item:hover {
    background: #f8f9fa;
}

.project-main {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.project-name {
    font-weight: 600;
    color: #212529;
    text-decoration: none;
    flex: 1;
}

.project-name:hover {
    color: #007bff;
}

.project-desc {
    font-size: 0.85em;
    color: #6c757d;
    margin: 2px 0 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-meta {
    display: flex;
    gap: 16px;
    font-size: 0.78em;
    color: #adb5bd;
}

.role-tag {
    font-size: 0.7em;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
}

.role-owner {
    background: #fff3cd;
    color: #856404;
}

.role-member {
    background: #cfe2ff;
    color: #084298;
}

/* User role tags */
.role-admin {
    background: #f3e8ff;
    color: #6b21a8;
}

.role-researcher {
    background: #cfe2ff;
    color: #084298;
}

.role-technician {
    background: #d1fae5;
    color: #065f46;
}

.role-editor {
    background: #fff3cd;
    color: #856404;
}

.role-viewer {
    background: #f3f4f6;
    color: #4b5563;
}

@media (max-width: 768px) {
    .dashboard-panels {
        grid-template-columns: 1fr;
    }
}

/* ── Rooms Page ─────────────────────────────────────────────── */

.rooms-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.room-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    transition: box-shadow 0.15s;
}

.room-card:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.room-card-inactive {
    opacity: 0.65;
    background: #f9fafb;
}

.room-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.room-card-title-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.room-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.room-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-active   { background: #22c55e; }
.dot-inactive { background: #d1d5db; }

.room-status-label {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-active {
    background: #dcfce7;
    color: #15803d;
}

.status-inactive {
    background: #f3f4f6;
    color: #6b7280;
}

.room-subject-badge {
    font-size: 0.82rem;
    font-weight: 600;
    background: #eff6ff;
    color: #1d4ed8;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    white-space: nowrap;
}

.room-card-desc {
    color: #6b7280;
    font-size: 0.9rem;
    margin: 0.25rem 0 0.75rem;
    line-height: 1.5;
}

.room-card-stats {
    display: flex;
    gap: 2rem;
    margin-bottom: 0.85rem;
}

.room-stat {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.room-stat-label {
    font-size: 0.72rem;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.room-stat-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: #374151;
}

.room-projects {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    border-top: 1px solid #f3f4f6;
    padding-top: 0.75rem;
}

.room-projects-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.room-project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.room-project-tag {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
    border-radius: 999px;
    font-size: 0.78rem;
    padding: 0.2rem 0.65rem;
    font-weight: 500;
}

.room-no-projects {
    font-size: 0.82rem;
    color: #9ca3af;
    margin: 0;
    padding-top: 0.75rem;
    border-top: 1px solid #f3f4f6;
}

/* Manage Rooms button */
.btn {
    display: inline-block;
    padding: 0.45rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: background 0.15s;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-primary:hover {
    background: #1d4ed8;
    color: #fff;
}

.btn-sm {
    padding: 0.35rem 0.85rem;
    font-size: 0.8rem;
}

/* ── Room Detail Page ───────────────────────────────────────── */

.back-link {
    display: inline-block;
    font-size: 0.82rem;
    color: #6b7280;
    text-decoration: none;
    margin-bottom: 0.4rem;
}

.back-link:hover { color: #2563eb; }

.room-detail-stats {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    padding-top: 0.25rem;
}

.room-detail-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
}

.room-detail-stat .room-stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #111827;
    line-height: 1;
}

.room-detail-stat .room-stat-label {
    font-size: 0.7rem;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

/* Cabinet grid */

.cabinet-grid-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.cabinet-row-group {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.cabinet-row-label {
    width: 2rem;
    min-width: 2rem;
    height: 2rem;
    background: #1e3a5f;
    color: #fff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    margin-top: 0.25rem;
    flex-shrink: 0;
}

.cabinet-row-cells {
    display: grid;
    grid-template-columns: repeat(var(--row-cols), minmax(110px, 1fr));
    gap: 0.6rem;
    flex: 1;
}

.cabinet-panel {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.75rem 0.85rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    transition: box-shadow 0.15s;
}

.cabinet-panel:hover:not(.cabinet-panel-empty) {
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.cabinet-panel-inactive {
    opacity: 0.5;
    background: #f9fafb;
}

.cabinet-panel-empty {
    background: transparent;
    border-color: transparent;
    pointer-events: none;
}

.cabinet-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.2rem;
}

.cabinet-label-text {
    font-size: 1rem;
    font-weight: 700;
    color: #1e3a5f;
    letter-spacing: 0.02em;
}

.cabinet-inactive-badge {
    font-size: 0.65rem;
    font-weight: 700;
    background: #f3f4f6;
    color: #9ca3af;
    border-radius: 4px;
    padding: 0.1rem 0.35rem;
    text-transform: uppercase;
}

.cabinet-readings {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.cabinet-reading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.reading-icon {
    width: 1.3rem;
    height: 1.3rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 800;
    flex-shrink: 0;
    letter-spacing: 0;
}

.temp-icon { background: #fee2e2; color: #b91c1c; }
.hum-icon  { background: #dbeafe; color: #1d4ed8; }
.lux-icon  { background: #fef9c3; color: #92400e; }

.reading-val {
    font-size: 0.88rem;
    font-weight: 600;
    color: #374151;
}

.reading-unit {
    font-size: 0.72rem;
    font-weight: 400;
    color: #9ca3af;
    margin-left: 1px;
}

.cabinet-reading-time {
    font-size: 0.68rem;
    color: #d1d5db;
    margin-top: 0.1rem;
}

.cabinet-no-data {
    font-size: 0.78rem;
    color: #d1d5db;
    font-style: italic;
    padding: 0.4rem 0;
}

/* Clickable room item in dashboard */
.room-item-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.room-item-link:hover .room-item {
    background: #f0f7ff;
}

.room-item-link:hover .room-name {
    color: #2563eb;
}

/* ── Projects Page ───────────────────────────────────────── */

.projects-page-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.project-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    transition: box-shadow 0.15s;
}

.project-card:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.project-card-inactive {
    opacity: 0.65;
    background: #f9fafb;
}

.project-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.project-card-title-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.project-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #111827;
    text-decoration: none;
}

.project-card-title:hover {
    color: #2563eb;
}

.project-inactive-badge {
    font-size: 0.7rem;
    font-weight: 700;
    background: #f3f4f6;
    color: #9ca3af;
    border-radius: 4px;
    padding: 0.15rem 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.project-card-desc {
    color: #6b7280;
    font-size: 0.9rem;
    margin: 0.25rem 0 0.75rem;
    line-height: 1.5;
}

.project-card-stats {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

/* ── Project Detail ─────────────────────────────────────── */

.project-section {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}

.project-section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #f3f4f6;
}

.project-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    margin: 0;
    flex: 1;
}

/* Subjects table */

.subject-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.subject-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.subject-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

.subject-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
    vertical-align: middle;
}

.subject-table tbody tr:last-child td {
    border-bottom: none;
}

.subject-table tbody tr:hover td {
    background: #f9fafb;
}

.subject-id {
    font-weight: 600;
    color: #111827;
    font-family: monospace;
    font-size: 0.9rem;
}

/* Clickable subject identifier linking to the subject detail page.
   Keeps the surrounding text styling and only adds a hover affordance. */
a.subject-link {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}
a.subject-link:hover {
    color: #2563eb;
    text-decoration: underline;
}

.sex-badge {
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sex-male    { background: #dbeafe; color: #1d4ed8; }
.sex-female  { background: #fce7f3; color: #9d174d; }
.sex-unknown { background: #f3f4f6; color: #6b7280; }

.loc-warning {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.70rem;
    font-weight: 600;
    background: #fef9c3;
    color: #854d0e;
    border: 1px solid #fde047;
    border-radius: 4px;
    padding: 0.15rem 0.45rem;
    white-space: nowrap;
    cursor: default;
}

/* ── Subject row: active but has a death date ── */
tr.dod-active-warning > td {
    background: #fff1f2 !important;
}
tr.dod-active-warning:hover > td {
    background: #ffe4e6 !important;
}
.dod-active-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.70rem;
    font-weight: 600;
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
    border-radius: 4px;
    padding: 0.15rem 0.45rem;
    white-space: nowrap;
    cursor: default;
    margin-left: 0.35rem;
    vertical-align: middle;
}

.feeding-badge {
    font-size: 0.72rem;
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
    border-radius: 4px;
    padding: 0.15rem 0.45rem;
    font-weight: 500;
    white-space: nowrap;
}

.room-link {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
}

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

/* Members list */

.members-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.member-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f3f4f6;
}

.member-row:last-child {
    border-bottom: none;
}

.member-avatar {
    width: 2rem;
    height: 2rem;
    background: #1e3a5f;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.member-name {
    font-weight: 600;
    color: #111827;
    min-width: 8rem;
}

.member-email {
    color: #9ca3af;
    font-size: 0.85rem;
    flex: 1;
}

/* ── Admin Room Cards with Cabinet Management ─────────────── */

.admin-room-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.admin-room-card {
    border-bottom: 1px solid #f3f4f6;
    padding: 0.85rem;
}

.admin-room-card:last-child {
    border-bottom: none;
}

.admin-room-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.admin-room-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 10rem;
}

.admin-room-name {
    font-size: 0.95rem;
    color: #111827;
}

.admin-room-desc {
    font-size: 0.8rem;
    color: #9ca3af;
}

.admin-room-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.admin-meta-chip {
    font-size: 0.75rem;
    background: #f3f4f6;
    color: #6b7280;
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    font-weight: 500;
}

.admin-room-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

/* Cabinet <details> */

.cabinet-details {
    margin-top: 0.6rem;
    margin-left: 0.25rem;
}

.cabinet-summary {
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    color: #6b7280;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0;
    list-style: none;
}

.cabinet-summary::-webkit-details-marker { display: none; }

.cabinet-summary::before {
    content: '▶';
    font-size: 0.6rem;
    color: #9ca3af;
    transition: transform 0.15s;
}

details[open] > .cabinet-summary::before {
    transform: rotate(90deg);
}

.cabinet-summary-count {
    background: #e0e7ff;
    color: #4338ca;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 999px;
    padding: 0.1rem 0.45rem;
}

.cabinet-details-body {
    margin-top: 0.75rem;
    padding: 1rem 1.25rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.add-cabinet-form {
    margin-bottom: 1rem;
}

.cabinet-table {
    margin-top: 0;
    font-size: 0.85rem;
}

.cabinet-empty-msg {
    font-size: 0.82rem;
    color: #9ca3af;
    font-style: italic;
    margin: 0;
}

/* ── API Keys Page ────────────────────────────────────────── */

.api-key-reveal {
    position: relative;
    padding: 1rem 1.25rem;
}

.api-key-display {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.6rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
}

.api-key-display code {
    font-family: monospace;
    font-size: 0.9rem;
    color: #166534;
    word-break: break-all;
    flex: 1;
}

.key-prefix {
    font-family: monospace;
    font-size: 0.85rem;
    color: #374151;
    background: #f3f4f6;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

.api-docs {
    padding: 0.25rem 1.25rem 1.25rem;
}

.api-doc-intro {
    font-size: 0.9rem;
    color: #6b7280;
    margin-bottom: 1rem;
}

.api-doc-section {
    font-size: 0.82rem;
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 1rem 0 0.4rem;
}

.api-code {
    background: #1e293b;
    color: #e2e8f0;
    border-radius: 6px;
    padding: 0.85rem 1rem;
    font-family: monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre;
}

/* ── Secondary button ──────────────────────────────────────── */
.btn-secondary {
    background: #e9ecef;
    color: #495057;
    border: 1px solid #ced4da;
}

.btn-secondary:hover {
    background: #dee2e6;
    color: #343a40;
}

/* ── Create Project Form ──────────────────────────────────── */

.cp-section {
    margin-bottom: 1.5rem;
}

.cp-help-text {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0 0 1.1rem;
    line-height: 1.5;
}

.cp-textarea {
    min-height: 80px;
    resize: vertical;
    width: 100%;
    font-family: inherit;
}

/* Subject pattern builder */
.cp-pattern-row {
    display: flex;
    align-items: flex-end;
    gap: 0;
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem 1.1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.cp-pattern-connector {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 0.35rem;
}

.cp-pattern-number-box {
    background: #1e3a5f;
    color: #fff;
    font-family: monospace;
    font-weight: 700;
    font-size: 1.1rem;
    border-radius: 6px;
    padding: 0.3rem 0.7rem;
    white-space: nowrap;
    min-width: 3rem;
    text-align: center;
}

.cp-end-mode-toggle {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    padding: 0.45rem 0;
}

.cp-radio-label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    white-space: nowrap;
}

/* Preview strip */
.cp-preview-strip {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.1rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 7px;
    padding: 0.55rem 1rem;
    flex-wrap: wrap;
}

.cp-preview-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #15803d;
    white-space: nowrap;
}

.cp-preview-ids {
    font-family: monospace;
    font-size: 0.88rem;
    color: #166534;
}

/* Member rows */
.cp-member-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
    flex-wrap: wrap;
}

.cp-member-select {
    flex: 2;
    min-width: 220px;
}

.cp-member-role-select {
    flex: 1;
    min-width: 140px;
}

.cp-add-member-btn {
    margin-top: 0.5rem;
}

/* Submit row */
.cp-submit-row {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 0.5rem 0 2rem;
}

/* ── Edit Subjects page ─────────────────────────────────── */
.es-table-outer {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border, #e5e7eb);
    margin-bottom: 1.5rem;
}

.es-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.es-table thead th {
    background: var(--panel-header-bg, #f8f9fa);
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary, #6b7280);
    border-bottom: 1px solid var(--border, #e5e7eb);
    white-space: nowrap;
}

.es-row {
    border-bottom: 1px solid var(--border, #e5e7eb);
    transition: background 0.1s;
}

.es-row:last-child {
    border-bottom: none;
}

.es-row:hover {
    background: var(--hover-bg, #f9fafb);
}

.es-table td {
    padding: 6px 8px;
    vertical-align: middle;
}

.es-input,
.es-select,
.es-textarea {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--border, #d1d5db);
    border-radius: 5px;
    font-size: 0.82rem;
    background: var(--input-bg, #fff);
    color: var(--text, #111);
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.es-input:focus,
.es-select:focus,
.es-textarea:focus {
    outline: none;
    border-color: #6c63ff;
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.1);
}

.es-textarea {
    resize: vertical;
    min-height: 34px;
    white-space: pre-wrap;
}

.es-input-date { min-width: 120px; }
.es-input-num  { min-width: 70px;  }

.es-col-id        { min-width: 80px;  }
.es-col-sex       { min-width: 90px;  }
.es-col-genotype  { min-width: 110px; }
.es-col-strain    { min-width: 110px; }
.es-col-dob       { min-width: 130px; }
.es-col-age       { min-width: 80px;  }
.es-col-feeding   { min-width: 160px; }
.es-col-fnotes    { min-width: 130px; }
.es-col-treatment { min-width: 110px; }
.es-col-room      { min-width: 120px; }
.es-col-notes     { min-width: 160px; }

.es-footer {
    display: flex;
    gap: 0.75rem;
    padding: 0 0 2rem;
}

/* ── Category management (project_detail) ────────────── */
.category-mgmt {
    margin-top: 1.25rem;
    padding: 14px 18px;
    background: var(--panel-bg, #f8f9fa);
    border: 1px dashed var(--border, #d1d5db);
    border-radius: 8px;
}

.category-mgmt-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary, #6b7280);
    margin: 0 0 10px;
}

.category-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.category-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--panel-header-bg, #e9ecef);
    border: 1px solid var(--border, #d1d5db);
    border-radius: 20px;
    padding: 3px 10px 3px 12px;
    font-size: 0.82rem;
    font-weight: 500;
}

.category-chip-del {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary, #9ca3af);
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
    transition: color 0.15s;
}
.category-chip-del:hover { color: #dc2626; }

.category-add-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.category-add-input {
    flex: 1;
    max-width: 260px;
    padding: 5px 10px;
    border: 1px solid var(--border, #d1d5db);
    border-radius: 6px;
    font-size: 0.82rem;
}
.category-add-input:focus {
    outline: none;
    border-color: #6c63ff;
    box-shadow: 0 0 0 3px rgba(108,99,255,0.1);
}

.es-hot-container {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border, #e5e7eb);
    margin-bottom: 1.5rem;
}

.es-status {
    font-size: 0.82rem;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.2s;
}

.es-status:not(:empty) { opacity: 1; }

.es-status-ok  { color: #16a34a; }
.es-status-err { color: #dc2626; }

/* ── Edit Project page ─────────────────────────────────────── */
.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.3rem;
}
.form-input {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0.45rem 0.7rem;
    font-size: 0.875rem;
    color: #111827;
    background: #fff;
    transition: border-color 0.15s;
}
.form-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.btn-danger-sm {
    font-size: 0.75rem;
    padding: 3px 10px;
    border: none;
    border-radius: 4px;
    background: #fee2e2;
    color: #991b1b;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.15s;
}
.btn-danger-sm:hover { background: #fca5a5; }

/* ── Data-view cards ──────────────────────────────────────────────────────── */
.data-views-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.25rem 0;
}
.data-view-card {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 1rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    text-decoration: none;
    color: #111827;
    font-weight: 500;
    font-size: 0.875rem;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    min-width: 180px;
}
.data-view-card:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    box-shadow: 0 1px 4px rgba(59,130,246,0.1);
}
.data-view-icon { font-size: 1.1rem; }
i.ph { vertical-align: -0.125em; line-height: 1; }
.data-view-name { flex: 1; }
.data-view-arrow { color: #9ca3af; font-size: 0.85rem; }

/* ── Modal overlay ────────────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.modal-open {
    display: flex;
}
.modal-box {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    width: 100%;
    max-width: 480px;
    margin: 1rem;
    overflow: hidden;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
}
.modal-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
}
.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    padding: 0 4px;
}
.modal-close:hover { color: #111827; }
.modal-body { padding: 1.25rem; overflow-y: auto; max-height: 60vh; }
.modal-intro {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 1rem;
}

/* ── Help widget floating button ─────────────────────────────────────────── */
.help-btn {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    color: #6b7280;
    z-index: 1500;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.help-btn:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #2563eb;
    box-shadow: 0 4px 12px rgba(37,99,235,0.15);
}

/* ── Viewer options inside Add Data modal ─────────────────────────────────── */
.viewer-options { display: flex; flex-direction: column; gap: 0.75rem; }
.viewer-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
}
.viewer-option-added {
    opacity: 0.6;
}
.viewer-option-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.viewer-option-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #111827;
}
.viewer-option-desc {
    font-size: 0.78rem;
    color: #6b7280;
}
.viewer-option-badge {
    font-size: 0.75rem;
    font-weight: 600;
    color: #059669;
    white-space: nowrap;
}
