:root {
    --bg-body: #ffffff;
    --bg-surface: #f3f4f6;
    --bg-card: #ffffff;
    --text-main: #111827;
    --text-soft: #6b7280;
    --text-strong: #111827;
    --border-color: #d1d5db;
}

html.dark-mode,
body.dark-mode {
    --bg-body: #0f172a;
    --bg-surface: #111827;
    --bg-card: #111827;
    --text-main: #e5e7eb;
    --text-soft: #94a3b8;
    --text-strong: #ffffff;
    --border-color: #1f2937;
}

html.light-mode,
body.light-mode {
    --bg-body: #ffffff;
    --bg-surface: #f3f4f6;
    --bg-card: #ffffff;
    --text-main: #111827;
    --text-soft: #6b7280;
    --text-strong: #111827;
    --border-color: #d1d5db;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: Arial, sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
}

.theme-toggle {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 999px;
    background: rgba(255,255,255,0.14);
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s ease, transform 0.2s ease;
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.22);
}

.theme-toggle:active {
    transform: scale(0.96);
}

.theme-icon {
    display: none;
    font-size: 18px;
    line-height: 1;
}

body.light-mode .theme-icon-sun {
    display: inline;
}

body.dark-mode .theme-icon-moon {
    display: inline;
}

html, body,
.hero-card,
.info-card,
.filters-card,
.table-card,
.stat-box,
.network-box,
.search-input,
.rows-select,
.recent-flight-row,
.award-modal-box,
thead th,
tbody tr,
td,
th {
    transition:
        background-color 0.25s ease,
        color 0.25s ease,
        border-color 0.25s ease,
        box-shadow 0.25s ease;
}

body.dark-mode tbody tr:hover {
    background: rgba(255,255,255,0.04);
}

body.dark-mode .pilot-code-inline {
    color: #93c5fd;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: 50px;
    background: #00103b;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dashboard-btn {
    background-color: #3C4B53;
    color: white;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 5px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

.main-container {
    flex: 1;
    padding: 24px;
}

.page {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.page-header h1 {
    margin: 0;
    font-size: 30px;
    color: var(--text-strong);
}

.page-header p {
    margin: 6px 0 0;
    color: var(--text-soft);
}

.filters-card,
.table-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
}

.filters-card {
    padding: 16px;
}

.search-input {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    background: var(--bg-card);
    color: var(--text-main);
}

.table-header {
    padding: 15px 20px;
    background: #00103b;
    color: #ffffff;
}

.table-header h2 {
    margin: 0;
    font-size: 18px;
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}

th,
td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    vertical-align: middle;
}

thead th {
    background: var(--bg-card);
    color: var(--text-strong);
    font-size: 13px;
    font-weight: 700;
}

tbody tr {
    background: var(--bg-surface);
}

tbody tr:hover {
    background: rgba(0, 16, 59, 0.04);
}

.sortable {
    cursor: pointer;
    user-select: none;
}

.sort-arrow {
    margin-left: 6px;
    opacity: 0.55;
    font-size: 11px;
}

.sorted-asc .sort-arrow::after {
    content: '▲';
}

.sorted-desc .sort-arrow::after {
    content: '▼';
}

.filters-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.rows-select {
    min-width: 90px;
    height: 42px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0 12px;
    font-size: 14px;
    background: var(--bg-card);
    color: var(--text-main);
}

/* Foto más grande */
.pilot-avatar-table {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #ffffff;
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

/* Ajustar algo más la columna avatar */
.col-avatar {
    width: 110px;
    min-width: 110px;
}

.pilot-admin-badge {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.pilot-admin-badge-profile {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.col-pilot {
    text-align: left;
    min-width: 340px;
}

.pilot-link {
    text-decoration: none;
    color: inherit;
    display: inline-flex;
    align-items: center;
}

.pilot-link:hover .pilot-name-inline {
    text-decoration: underline;
}

.pilot-line-main {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ivao-link {
    color: #478ac9;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.ivao-link:hover {
    color: #2f6fa8;
    text-decoration: none;
}

body.dark-mode .ivao-link:hover {
    color: #6fb0e4;
}

.pilot-country-flag {
    width: 24px;
    height: 16px;
    object-fit: contain;
    border-radius: 3px;
}

.pilot-rank-inline {
    height: 22px;
    width: auto;
    object-fit: contain;
}

.pilot-code-inline {
    font-size: 13px;
    font-weight: 700;
    color: #00103b;
}

.pilot-name-inline {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-strong);
}

.table-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-surface);
}

.pagination-btn {
    border: none;
    border-radius: 10px;
    padding: 9px 14px;
    font-weight: 700;
    cursor: pointer;
    background: #00103b;
    color: #ffffff;
    transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: #001a5e;
    transform: translateY(-1px);
}

.pagination-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-soft);
    min-width: 110px;
    text-align: center;
}

/* 🔥 MODO EMBED */
.page-wrapper {
    max-width: 100%;
}

/* Evita espacios raros */
.table-container {
    margin: 0;
    padding: 0;
}

/* Paginación centrada */
.pagination-wrapper {
    margin-top: 20px;
    display: flex;
    justify-content: center;
}

@media (max-width: 700px) {
    .filters-row {
        flex-direction: column;
        align-items: stretch;
    }

    .rows-select {
        width: 100%;
    }
}