/* Reset and Tokens */
:root {
    --bg-app: #f5f8f8;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-soft: #f0f5f6;
    --bg-soft-2: #e6eef0;
    --border-color: #d9e6ea;
    --text-primary: #1f2f39;
    --text-secondary: #5d7280;
    --text-muted: #7f939f;

    --accent-blue: #4ea7cf;
    --accent-indigo: #5a9d8a;
    --accent-emerald: #2b9f85;
    --accent-amber: #f0b659;
    --accent-rose: #de7f8f;

    --link-color: #2f7fa8;
    --link-hover: #205f7f;
    --link-visited: #4c6f8a;
    --focus-ring: rgba(46, 125, 167, 0.38);

    --font-sans: "Manrope", "Segoe UI", sans-serif;
    --font-display: "Sora", "Manrope", sans-serif;

    --transition-fast: 0.18s ease;
    --transition-normal: 0.3s ease;

    --shadow-sm: 0 1px 2px rgba(34, 62, 75, 0.06);
    --shadow-md: 0 8px 18px rgba(34, 62, 75, 0.07);
    --shadow-lg: 0 14px 28px rgba(34, 62, 75, 0.11);
    --shadow-xl: 0 24px 52px rgba(34, 62, 75, 0.18);
}

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

[v-cloak] {
    display: none;
}

html,
body {
    min-height: 100%;
}

body {
    background:
        radial-gradient(circle at 4% 10%, #ddeef3 0%, rgba(221, 238, 243, 0) 26%),
        radial-gradient(circle at 92% 2%, #e1f6ed 0%, rgba(225, 246, 237, 0) 24%),
        linear-gradient(160deg, #f8fbfc 0%, #f0f6f7 50%, #eef4f5 100%);
    color: var(--text-primary);
    font-family: var(--font-sans);
    overflow-x: hidden;
}

a {
    color: var(--link-color);
    text-decoration-color: rgba(47, 127, 168, 0.45);
    text-underline-offset: 2px;
    text-decoration-thickness: 1.2px;
}

a:hover {
    color: var(--link-hover);
    text-decoration-color: rgba(32, 95, 127, 0.6);
}

a:visited {
    color: var(--link-visited);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

/* App Shell */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 252px;
    background: linear-gradient(180deg, #fcfefe 0%, #f6fbfb 100%);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 28px 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: #284a58;
}

.sidebar-nav {
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-item {
    border: none;
    border-radius: 14px;
    padding: 12px 14px;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 700;
    background: transparent;
    cursor: pointer;
    text-align: left;
    transition: var(--transition-fast);
}

.nav-item:hover {
    background-color: #edf6f8;
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, #d8f3ee 0%, #ebf8fb 100%);
    color: #256a73;
    box-shadow: inset 0 0 0 1px rgba(88, 162, 184, 0.35);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.version {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.main-content {
    flex: 1;
    margin-left: 252px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.top-header {
    background: rgba(250, 252, 252, 0.9);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-color);
    padding: 18px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 90;
}

.top-header h1 {
    font-family: var(--font-display);
    font-size: 29px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: #223843;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-bar-container {
    width: min(100%, 340px);
}

.search-bar-container input {
    width: 100%;
    border: 1px solid #c7dbe1;
    background: #ffffff;
    border-radius: 999px;
    color: var(--text-primary);
    padding: 10px 16px;
    font-size: 14px;
    font-family: var(--font-sans);
    transition: var(--transition-fast);
}

.search-bar-container input::placeholder {
    color: #8da2ae;
}

.search-bar-container input:focus {
    border-color: #6eb4ca;
    box-shadow: 0 0 0 3px rgba(109, 180, 202, 0.2);
}

.header-action {
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #2f9f86 0%, #4aa8cd 100%);
    color: #ffffff;
    font-weight: 700;
    font-family: var(--font-sans);
    font-size: 13px;
    padding: 10px 16px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.header-action:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.content-wrapper {
    padding: 28px;
    flex: 1;
}

.view-section {
    display: none;
    animation: fadeIn 0.36s ease;
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(9px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Cards and Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: linear-gradient(168deg, #ffffff 0%, #f8fcfd 100%);
    border: 1px solid #d6e7eb;
    border-radius: 16px;
    padding: 18px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #76909b;
    font-weight: 700;
}

.stat-value {
    margin-top: 7px;
    font-size: 31px;
    line-height: 1.05;
    font-weight: 700;
    color: #21424f;
    font-family: var(--font-display);
}

.dashboard-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
}

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

.card {
    background: var(--bg-card);
    border: 1px solid #d5e4e9;
    border-radius: 18px;
    padding: 20px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
}

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

.card-header h2 {
    font-family: var(--font-display);
    font-size: 19px;
    letter-spacing: -0.01em;
    color: #25424f;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.summary-pill {
    border: 1px solid #d8e8ed;
    background: #f6fbfc;
    border-radius: 11px;
    padding: 11px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.summary-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 700;
    color: #7895a1;
}

.summary-value {
    font-size: 16px;
    color: #2b4b58;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 260px;
}

/* List Items */
.recent-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 12px;
    border: 1px solid #d6e6eb;
    border-radius: 12px;
    background: #fcfefe;
    cursor: pointer;
    transition: var(--transition-fast);
}

.recent-item:hover {
    transform: translateY(-1px);
    border-color: #9bc7d8;
    box-shadow: var(--shadow-md);
}

.item-main {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.item-title {
    font-size: 14px;
    font-weight: 700;
    color: #203741;
}

.item-subtitle {
    font-size: 12px;
    color: #66828f;
}

.item-meta {
    font-size: 11px;
    font-weight: 700;
    color: #2d7f91;
    border-radius: 999px;
    background: #e8f5f8;
    padding: 4px 9px;
    white-space: nowrap;
}

/* Split Views */
.split-view {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 18px;
    height: calc(100vh - 148px);
}

.split-list-panel,
.split-detail-panel {
    background: #ffffff;
    border: 1px solid #d6e5ea;
    border-radius: 18px;
    box-shadow: var(--shadow-sm);
}

.split-list-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.panel-header {
    border-bottom: 1px solid #ddeaf0;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.panel-header h2 {
    font-size: 18px;
    font-family: var(--font-display);
    color: #23424f;
}

.directory-list {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.directory-item {
    border: 1px solid #d8e6ec;
    border-radius: 12px;
    padding: 12px;
    background: #fbfeff;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.directory-item:hover {
    border-color: #96c2d2;
    box-shadow: var(--shadow-md);
}

.directory-item.active {
    background: linear-gradient(140deg, #ecf8f6 0%, #f1f9fc 100%);
    border-color: #81b6c8;
}

.directory-item-title {
    font-size: 14px;
    color: #1f3843;
    font-weight: 700;
}

.directory-item-subtitle {
    font-size: 12px;
    color: #688592;
}

.directory-item-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 2px;
}

.tag {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 4px 7px;
    border-radius: 999px;
    text-transform: uppercase;
}

.tag.blue {
    color: #2f7a9b;
    background: #e6f3f8;
}

.tag.purple {
    color: #447971;
    background: #e7f4ef;
}

.tag.green {
    color: #287868;
    background: #def4eb;
}

.split-detail-panel {
    padding: 20px;
    overflow-y: auto;
    min-height: 0;
}

.mobile-back-btn {
    border: 1px solid #bcd8e2;
    border-radius: 999px;
    background: #f0f8fb;
    color: #26586c;
    font-size: 12px;
    font-weight: 700;
    padding: 8px 12px;
    margin-bottom: 12px;
    cursor: pointer;
}

.mobile-back-btn:hover {
    background: #e7f4f9;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #6d8693;
    min-height: 240px;
    height: 100%;
    padding: 22px;
}

.empty-state h3 {
    font-family: var(--font-display);
    font-size: 21px;
    color: #2a4854;
    margin-bottom: 6px;
}

/* Detail Views */
.detail-header,
.profile-header {
    border-bottom: 1px solid #dbe9ee;
    padding-bottom: 16px;
    margin-bottom: 16px;
}

.detail-title,
.profile-name {
    font-family: var(--font-display);
    color: #1f3a46;
}

.detail-title {
    font-size: 28px;
    margin-bottom: 8px;
}

.detail-metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
    color: #678290;
}

.meta-item {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid #d7e6eb;
    background: #f8fcfd;
}

.event-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.tab-btn {
    border: 1px solid #d3e4ea;
    border-radius: 999px;
    background: #fbfefe;
    color: #567180;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-fast);
}

.tab-btn:hover {
    border-color: #9ac4d4;
    color: #254857;
}

.tab-btn.active {
    background: linear-gradient(132deg, #2f9f86 0%, #4ca8cd 100%);
    border-color: transparent;
    color: #ffffff;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    border-radius: 14px;
    border: 1px solid #d7e7ed;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

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

.leaderboard-table th {
    background: #f4fafb;
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #6f8a97;
    font-weight: 800;
}

.leaderboard-table tbody tr {
    transition: var(--transition-fast);
}

.leaderboard-table tbody tr:hover {
    background: #f6fbfc;
}

.leaderboard-table tbody tr.podium-1 {
    background: rgba(240, 182, 89, 0.12);
}

.leaderboard-table tbody tr.podium-2 {
    background: rgba(122, 145, 160, 0.08);
}

.leaderboard-table tbody tr.podium-3 {
    background: rgba(206, 151, 101, 0.12);
}

.rank-badge {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #e6f0f3;
    color: #2c4a57;
    font-size: 11px;
    font-weight: 800;
}

.podium-1 .rank-badge {
    background-color: var(--accent-amber);
    color: #2a1e0a;
}

.podium-2 .rank-badge {
    background-color: #c8d5dc;
    color: #2d3f49;
}

.podium-3 .rank-badge {
    background-color: #c99059;
    color: #ffffff;
}

.sailor-names {
    display: flex;
    flex-direction: column;
}

.skipper-name {
    font-weight: 700;
}

.crew-name {
    font-size: 12px;
    color: #5c7b89;
}

.discard {
    color: #879ca8;
    text-decoration: line-through;
}

.points {
    color: #266f8d;
    font-weight: 700;
}

/* Profile and Country Panels */
.profile-title-area {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.profile-name {
    font-size: 30px;
}

.profile-country {
    font-size: 15px;
    color: #617c8b;
}

.profile-aka-container {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.aka-badge {
    border: 1px solid #d4e4ea;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 11px;
    color: #5f7987;
    background: #f6fbfd;
}

.profile-details,
.country-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.profile-detail-card {
    background: #f8fcfd;
    border: 1px solid #d6e7ed;
    border-radius: 12px;
    padding: 14px;
}

.profile-detail-label {
    font-size: 11px;
    color: #6c8794;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.profile-detail-value {
    margin-top: 4px;
    font-size: 17px;
    color: #21414d;
    font-weight: 700;
}

.country-chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(244, 250, 252, 0.8);
    backdrop-filter: blur(6px);
}

.modal-content {
    width: min(680px, 94%);
    margin: 6vh auto;
    padding: 24px;
    border-radius: 18px;
    border: 1px solid #d5e6ec;
    background: #ffffff;
    box-shadow: var(--shadow-xl);
    animation: modalSlide 0.28s ease;
}

@keyframes modalSlide {
    from {
        transform: translateY(-18px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #deebf0;
    margin-bottom: 16px;
    padding-bottom: 12px;
}

.modal-header h2 {
    font-family: var(--font-display);
    color: #2b4652;
}

.close-btn {
    color: #64808f;
    font-size: 28px;
    font-weight: 600;
    cursor: pointer;
}

.close-btn:hover {
    color: #2b4f5f;
}

.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.modal-cell {
    border: 1px solid #d5e8ef;
    border-radius: 10px;
    background: #f9fcfd;
    padding: 10px;
}

/* Search Inputs */
.input-with-button {
    display: flex;
    gap: 8px;
}

.input-with-button input {
    flex: 1;
    border: 1px solid #cfe0e6;
    border-radius: 999px;
    background: #ffffff;
    color: var(--text-primary);
    padding: 9px 14px;
    font-size: 13px;
    transition: var(--transition-fast);
}

.input-with-button input::placeholder {
    color: #87a0ad;
}

.input-with-button input:focus {
    border-color: #6eb3ca;
    box-shadow: 0 0 0 3px rgba(109, 179, 202, 0.2);
}

.input-with-button button {
    border: none;
    border-radius: 999px;
    padding: 9px 14px;
    background: linear-gradient(135deg, #2e9f86 0%, #50a8cd 100%);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-fast);
}

.input-with-button button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Spinner */
.loading-spinner {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 3px solid #d9e9ef;
    border-top-color: #4ca8cd;
    margin: 34px auto;
    animation: spin 0.9s linear infinite;
}

/* Head to Head */
.h2h-picker + .h2h-picker {
    margin-top: 14px;
}

.h2h-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.h2h-picker-header h3 {
    font-family: var(--font-display);
    font-size: 15px;
    color: #25424f;
}

.h2h-picker-hint {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
}

.h2h-list {
    max-height: 240px;
    overflow-y: auto;
}

.h2h-group-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 700;
    padding: 8px 4px 4px;
}

.h2h-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid #d6e6eb;
    border-radius: 12px;
    background: #f6fbfc;
    padding: 10px 12px;
}

.h2h-selected-main {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.h2h-selected-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.h2h-selected-sub {
    font-size: 12px;
    color: var(--text-secondary);
}

.h2h-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.h2h-btn {
    border: 1px solid #c7dbe1;
    background: #ffffff;
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--link-color);
    cursor: pointer;
    transition: var(--transition-fast);
}

.h2h-btn:hover {
    background: #eef6f8;
    border-color: #6eb4ca;
}

.h2h-record {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.rank-badge.h2h-win-badge {
    background-color: #2b9f85;
    color: #ffffff;
    box-shadow: 0 0 0 2px rgba(43, 159, 133, 0.25);
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Responsive */
@media (max-width: 1280px) {
    .sidebar {
        width: 220px;
    }

    .main-content {
        margin-left: 220px;
    }

    .split-view {
        grid-template-columns: 280px minmax(0, 1fr);
    }
}

@media (max-width: 1180px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: sticky;
        top: 0;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        z-index: 130;
    }

    .sidebar-header {
        padding: 14px 16px;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 10px 12px 12px;
        gap: 8px;
    }

    .nav-item {
        white-space: nowrap;
        flex: 0 0 auto;
    }

    .sidebar-footer {
        display: none;
    }

    .main-content {
        margin-left: 0;
        min-height: auto;
    }

    .top-header {
        position: static;
        padding: 14px;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .top-header h1 {
        font-size: 24px;
    }

    .header-controls {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .search-bar-container {
        width: 100%;
    }

    .content-wrapper {
        padding: 14px;
    }

    .dashboard-layout,
    .country-chart-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-full-width {
        grid-column: 1;
    }

    .split-view {
        grid-template-columns: 1fr;
        height: auto;
    }

    .split-list-panel,
    .split-detail-panel {
        min-height: 0;
    }

    .split-view.mobile-focus-detail .split-list-panel {
        display: none;
    }

    .split-view.mobile-focus-detail .split-detail-panel {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .top-header h1 {
        font-size: 20px;
    }

    .card,
    .split-detail-panel {
        padding: 14px;
    }

    .panel-header {
        padding: 12px;
    }

    .directory-list {
        padding: 10px;
    }

    .detail-title {
        font-size: 23px;
    }

    .profile-name {
        font-size: 24px;
    }

    .profile-details,
    .country-kpi-grid,
    .country-chart-grid,
    .summary-grid,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .input-with-button {
        flex-direction: column;
    }

    .input-with-button button {
        width: 100%;
    }

    .modal-grid {
        grid-template-columns: 1fr;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 10px 8px;
    }
}
