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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: #1a1a2e;
    background: #f5f5f7;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Navbar */
.navbar {
    background: #1a1a2e;
    padding: 0.75rem 0;
}

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

.nav-brand {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
}

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

.nav-user {
    color: #a0a0b8;
    font-size: 0.875rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    color: #1a1a2e;
    text-decoration: none;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s;
}

.btn:hover {
    background: #eee;
}

.btn-primary {
    background: #4361ee;
    color: #fff;
    border-color: #4361ee;
}

.btn-primary:hover {
    background: #3a56d4;
}

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

.btn-block {
    display: block;
    width: 100%;
    text-align: center;
}

.inline {
    display: inline;
}

/* Hero */
.hero {
    text-align: center;
    padding: 4rem 1rem;
}

.hero h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.hero p {
    color: #555;
    margin-bottom: 1.5rem;
}

.hero-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

/* Auth forms */
.auth-form {
    max-width: 400px;
    margin: 3rem auto;
    background: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.auth-form h2 {
    margin-bottom: 1.5rem;
    text-align: center;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
}

.form-group input:focus {
    outline: none;
    border-color: #4361ee;
    box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.15);
}

.auth-form .btn-block {
    margin-top: 1.5rem;
}

.auth-link {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.875rem;
    color: #555;
}

.auth-link a {
    color: #4361ee;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Danger button */
.btn-danger {
    background: #dc2626;
    color: #fff;
    border-color: #dc2626;
}

.btn-danger:hover {
    background: #b91c1c;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

.table th,
.table td {
    padding: 0.6rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid #eee;
    font-size: 0.875rem;
}

.table th {
    background: #f9fafb;
    font-weight: 600;
    color: #555;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

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

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-idle { background: #e5e7eb; color: #374151; }
.badge-running { background: #dbeafe; color: #1d4ed8; }
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-error { background: #fef2f2; color: #991b1b; }

/* Admin page */
.admin-page {
    padding: 2rem 0;
}

.admin-page h1 {
    margin-bottom: 1rem;
}

.admin-page h2 {
    margin: 1.5rem 0 0.75rem;
    font-size: 1.1rem;
}

.admin-nav {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

/* Small text */
.text-error {
    color: #991b1b;
    font-size: 0.75rem;
    display: inline-block;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Inputs */
.input {
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.875rem;
}

.input:focus {
    outline: none;
    border-color: #4361ee;
    box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.15);
}

.input-sm {
    padding: 0.3rem 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.8rem;
    width: 80px;
}

/* Inline form */
.form-inline {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

/* ── Browse page ─────────────────────────────────────────────────── */

.container:has(.browse-page) {
    max-width: 1200px;
}

.browse-page {
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem 0;
    min-height: calc(100vh - 60px);
}

.browse-sidebar {
    width: 300px;
    flex-shrink: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    align-self: flex-start;
}

.browse-sidebar h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #555;
    margin-bottom: 0.75rem;
}

.browse-main {
    flex: 1;
    min-width: 0;
}

.browse-welcome {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 3rem 2rem;
    text-align: center;
}

.browse-welcome h2 { margin-bottom: 0.5rem; }
.browse-welcome p { color: #555; }

/* Tree */
.tree, .tree-children {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tree-children {
    padding-left: 1.25rem;
}

.tree-node { margin-bottom: 2px; }

.tree-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.tree-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.6rem;
    color: #888;
    padding: 0.2rem;
    transition: transform 0.15s;
    flex-shrink: 0;
    width: 1.2rem;
    text-align: center;
}

.tree-toggle-expanded {
    transform: rotate(90deg);
}

.tree-label {
    font-size: 0.85rem;
    color: #1a1a2e;
    text-decoration: none;
    padding: 0.15rem 0.3rem;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

a.tree-label:hover {
    background: #f0f0f5;
    color: #4361ee;
}

.tree-sport {
    font-weight: 600;
    font-size: 0.9rem;
}

.tree-country {
    color: #888;
    font-size: 0.8rem;
}

.tree-leaf {
    padding-left: 1.45rem;
    margin-bottom: 1px;
}

.tree-loading {
    color: #999;
    font-size: 0.8rem;
    font-style: italic;
}

.tree-empty {
    color: #999;
    font-size: 0.8rem;
    padding: 0.5rem 0;
}

/* Detail card */
.detail-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
}

.detail-card h2 {
    margin-bottom: 0.25rem;
}

.detail-card h3 {
    margin: 1.5rem 0 0.75rem;
    font-size: 1rem;
    color: #555;
}

.detail-subtitle {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.detail-field {
    font-size: 0.875rem;
}

.detail-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.1rem;
}

/* Alpine cloak */
[x-cloak] { display: none !important; }

@media (max-width: 768px) {
    .browse-page {
        flex-direction: column;
    }
    .browse-sidebar {
        width: 100%;
        position: static;
        max-height: 40vh;
    }
}

/* Progress info */
.progress-info {
    font-size: 0.8rem;
}

.progress-info small {
    display: block;
    color: #666;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
