* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    line-height: 1.5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

header {
    background: linear-gradient(135deg, #1a365d 0%, #2c5282 100%);
    color: white;
    padding: 24px 0;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
}

nav {
    background-color: #2d3748;
    padding: 0;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    position: relative;
}

nav a {
    display: inline-block;
    color: #e2e8f0;
    text-decoration: none;
    padding: 12px 20px;
    transition: background-color 0.2s;
}

nav a:hover {
    background-color: #4a5568;
    color: white;
}

/* Dropdown groups in the admin nav */
nav .dropdown {
    position: relative;
}

nav .dropdown > .drop-label {
    display: inline-block;
    background: none;
    border: none;
    border-radius: 0;
    color: #e2e8f0;
    font: inherit;
    padding: 12px 20px;
    cursor: pointer;
    transition: background-color 0.2s;
}

nav .dropdown > .drop-label .caret {
    font-size: 0.75rem;
    margin-left: 4px;
    opacity: 0.8;
}

nav .dropdown > .drop-label:hover,
nav .dropdown.active > .drop-label {
    background-color: #4a5568;
    color: white;
}

nav .dropdown:hover > .drop-label,
nav .dropdown:focus-within > .drop-label {
    background-color: #4a5568;
    color: white;
}

nav .dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background-color: #2d3748;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    z-index: 50;
    border-top: 2px solid #4a5568;
}

nav .dropdown:hover .dropdown-menu,
nav .dropdown:focus-within .dropdown-menu {
    display: block;
}

nav .dropdown-menu a {
    display: block;
    padding: 10px 20px;
    font-size: 0.9rem;
}

nav .dropdown-menu a:hover {
    background-color: #4a5568;
}

/* Right-aligned events switch + logout */
nav .nav-right {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
}

nav .event-switch select {
    padding: 5px 8px;
    border: 1px solid #4a5568;
    border-radius: 4px;
    background: #1a202c;
    color: #e2e8f0;
    font-size: 0.85rem;
    max-width: 220px;
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card h2, .card h3 {
    margin-bottom: 16px;
    color: #2d3748;
    font-size: 1.125rem;
}

.pipeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pipeline-header h2 {
    margin: 0;
}

/* Status badges - Event & Pipeline */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge-sm {
    padding: 2px 8px;
    font-size: 11px;
}

/* CREATED -> gray */
.status-created,
.status-pending {
    background-color: #e2e8f0;
    color: #4a5568;
}

/* PHOTOS_UPLOADED -> blue */
.status-photos-uploaded {
    background-color: #bee3f8;
    color: #2b6cb0;
}

/* IN_PROGRESS -> orange */
.status-processing {
    background-color: #feebc8;
    color: #c05621;
}

/* COMPLETED -> green */
.status-completed {
    background-color: #c6f6d5;
    color: #276749;
}

/* FAILED -> red */
.status-failed {
    background-color: #fed7d7;
    color: #c53030;
}

/* Gallery moderation status */
.gallery-status-unconfirmed {
    background-color: #feebc8;
    color: #c05621;
}

.gallery-status-confirmed {
    background-color: #c6f6d5;
    color: #276749;
}

.gallery-status-rejected {
    background-color: #fed7d7;
    color: #c53030;
}

.gallery-status-suggested {
    background-color: #bee3f8;
    color: #2b6cb0;
}

/* RunnerPhoto verification strength */
.verify-strong {
    background-color: #c6f6d5;
    color: #276749;
}

.verify-moderate {
    background-color: #feebc8;
    color: #c05621;
}

.verify-weak {
    background-color: #e2e8f0;
    color: #744210;
}

/* Gallery face verification score */
.face-matched {
    color: #276749;
    font-weight: 600;
}

.face-weak {
    color: #a0aec0;
}

.crowded-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    background-color: #fefcbf;
    color: #975a16;
    cursor: help;
}

/* Pipeline phases */
.pipeline-phase {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
    padding: 16px;
    background: #f7fafc;
    border-radius: 6px;
    border-left: 4px solid #cbd5e0;
}

.pipeline-phase.completed {
    border-left-color: #48bb78;
}

.pipeline-phase.failed {
    border-left-color: #f56565;
}

.pipeline-phase.in-progress {
    border-left-color: #ed8936;
}

.phase-main {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
}

.phase-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.phase-meta {
    font-size: 12px;
    color: #718096;
}

.phase-duration {
    font-size: 14px;
    font-weight: 700;
    color: #2b6cb0;
}

.phase-error {
    width: 100%;
    font-size: 12px;
    color: #c53030;
    margin-top: 4px;
}

.phase-actions {
    margin-left: auto;
}

/* Buttons */
button, .btn {
    padding: 10px 20px;
    background-color: #4299e1;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
    text-decoration: none;
    display: inline-block;
}

button:hover:not(:disabled), .btn:hover {
    background-color: #3182ce;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-success {
    background-color: #38a169;
}

.btn-success:hover {
    background-color: #2f855a;
}

.btn-danger {
    background-color: #e53e3e;
}

.btn-danger:hover {
    background-color: #c53030;
}

.btn-secondary {
    background-color: #718096;
}

.btn-secondary:hover {
    background-color: #4a5568;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* Forms */
.form-container {
    background: white;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    max-width: 600px;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #2d3748;
}

label .required {
    color: #e53e3e;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="file"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.2);
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

th {
    background-color: #2d3748;
    color: white;
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid #e2e8f0;
}

tr:hover {
    background-color: #f7fafc;
}

tr:last-child td {
    border-bottom: none;
}

/* Alerts */
.alert {
    padding: 14px 18px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.alert-success {
    background-color: #c6f6d5;
    color: #276749;
    border: 1px solid #9ae6b4;
}

.alert-error {
    background-color: #fed7d7;
    color: #c53030;
    border: 1px solid #feb2b2;
}

.alert-info {
    background-color: #bee3f8;
    color: #2b6cb0;
    border: 1px solid #90cdf4;
}

/* Gallery */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.gallery-item {
    background: white;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.gallery-item img {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.gallery-item-info {
    padding: 10px;
}

/* Runner info */
.runner-info {
    background: white;
    padding: 24px;
    border-radius: 8px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.runner-info p {
    margin: 8px 0;
    color: #4a5568;
}

/* Dashboard */
.dashboard-section {
    margin-bottom: 32px;
}

.dashboard-section h3 {
    margin-bottom: 16px;
    color: #2d3748;
}

.main-menu {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
}

.menu-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 24px;
    text-decoration: none;
    color: #2d3748;
    transition: transform 0.2s, box-shadow 0.2s;
}

.menu-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.menu-card h2 {
    font-size: 18px;
    margin-bottom: 8px;
}

.menu-card p {
    font-size: 14px;
    color: #718096;
}

/* Misc */
.back-link {
    display: inline-block;
    margin-bottom: 20px;
    color: #4299e1;
    text-decoration: none;
}

.back-link:hover {
    text-decoration: underline;
}

.muted {
    color: #718096;
    font-style: italic;
}

.error-text {
    color: #e53e3e;
    font-size: 12px;
    margin-top: 4px;
}

.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}

.file-input-wrapper input[type=file] {
    position: absolute;
    left: -9999px;
}

.file-input-label {
    display: block;
    padding: 12px;
    background-color: #f7fafc;
    border: 2px dashed #cbd5e0;
    border-radius: 6px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.file-input-label:hover {
    background-color: #edf2f7;
    border-color: #a0aec0;
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    .pipeline-header {
        flex-direction: column;
        align-items: flex-start;
    }

    nav a,
    nav .dropdown > .drop-label {
        padding: 10px 14px;
    }

    nav .nav-right {
        margin-left: 0;
        width: 100%;
        padding: 6px 14px 10px;
        flex-wrap: wrap;
    }

    nav .event-switch select {
        max-width: 100%;
    }

    nav .dropdown-menu {
        left: 0;
    }
}

.file-list {
    margin-top: 8px;
    padding-left: 20px;
}

.file-list li {
    font-size: 0.9rem;
    color: #333;
}

/* Gallery Moderation */
.gallery-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.gallery-preview {
    width: 100%;
    height: 180px;
    background-color: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.no-preview {
    color: #718096;
    font-size: 14px;
}

.gallery-info {
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
}

.bib-number {
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    margin: 0;
}

.gallery-actions {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gallery-actions .btn {
    width: 100%;
    text-align: center;
}

.gallery-actions form {
    margin: 0;
}

.w-full {
    width: 100%;
}

.grid {
    display: grid;
}

.grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
}

.gap-6 {
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .md\:grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    .xl\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.mb-6 {
    margin-bottom: 1.5rem;
}

.justify-between {
    justify-content: space-between;
}

.items-center {
    align-items: center;
}

.flex {
    display: flex;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #718096;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.gallery-status {
    color: #718096;
    font-size: 14px;
}

.gallery-actions-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.runner-name-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 50;
    background: white;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    max-height: 240px;
    overflow-y: auto;
}

.runner-name-option {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.runner-name-option:hover {
    background: #ebf8ff;
}

.runner-name-wrapper {
    position: relative;
}

.photo-item {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.photo-item.photo-declined {
    opacity: 0.7;
}

.photo-wrapper {
    position: relative;
    width: 100%;
    height: 200px;
    background-color: #e2e8f0;
}

.photo-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.declined-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(197, 48, 48, 0.7);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    /* Label only: let double-clicks pass through to the photo beneath so the
       lightbox opens for DECLINED photos too (and the copy-filename button
       stays clickable). */
    pointer-events: none;
}

.declined-badge {
    color: #c53030;
    font-weight: 700;
}

.photo-actions {
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.photo-status {
    font-size: 12px;
    color: #718096;
    text-transform: uppercase;
    font-weight: 500;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

nav a.active {
    background-color: #4a5568;
    color: white;
    font-weight: 600;
}

/* Copy filename button (photo grid) */
.copy-filename-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background-color: rgba(0, 0, 0, 0.55);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.copy-filename-btn:hover {
    background-color: rgba(0, 0, 0, 0.85);
}

.copy-tooltip {
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    white-space: nowrap;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    background-color: #2d3748;
    color: white;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s;
    pointer-events: none;
    z-index: 10;
}

.copy-filename-btn:hover .copy-tooltip,
.copy-filename-btn:focus .copy-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Copy filename button (table cell) */
.copy-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.crop-file-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 320px;
}

.crop-file-name {
    font-family: monospace;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.copy-filename-btn-inline {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    padding: 0;
    background-color: #4a5568;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.copy-filename-btn-inline:hover {
    background-color: #2d3748;
}

.copy-filename-btn-inline:hover .copy-tooltip,
.copy-filename-btn-inline:focus .copy-tooltip {
    opacity: 1;
    visibility: visible;
}

.copy-filename-btn-inline:active .copy-tooltip {
    transition: opacity 0s;
}
/* Logout link in the admin nav */
nav a.logout-link {
    background: #9b2c2c;
    border-radius: 4px;
}

nav a.logout-link:hover {
    background: #c53030;
    color: white;
}
