: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;
}

html,
body {
    background: var(--bg-body);
}

.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;
}

body.dark-mode .pilot-callsign {
    color: #93c5fd;
}

html, body,
.hero-card,
.info-card,
.stat-box,
.network-box,
.award-item img,
.award-modal-box,
.recent-flight-row,
.live-embed-wrap {
    transition:
        background-color 0.25s ease,
        color 0.25s ease,
        border-color 0.25s ease,
        box-shadow 0.25s ease;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: Arial, sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
}

.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,
.edit-profile-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;
}

.edit-profile-btn {
    background: #16a34a;
}

.main-container {
    flex: 1;
    padding: 24px;
}

.page {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.hero-card,
.info-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
}

.hero-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.pilot-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #ffffff;
    box-shadow: 0 10px 24px rgba(0,0,0,0.12);
}

.hero-main {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pilot-name-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pilot-name-row h1 {
    margin: 0;
    font-size: 30px;
    color: var(--text-strong);
}

.country-flag {
    width: 28px;
    height: 20px;
    object-fit: contain;
    border-radius: 4px;
}

.pilot-admin-badge-profile {
    width: 28px;
    height: 20px;
    object-fit: contain;
}

.pilot-callsign {
    font-size: 18px;
    font-weight: 700;
    color: #00103b;
}

.rank-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rank-image {
    height: 46px;
    width: auto;
    object-fit: contain;
}

.rank-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rank-name {
    font-size: 16px;
    font-weight: 700;
}

.rank-airports {
    font-size: 13px;
    color: var(--text-soft);
}

.grid-two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.info-card h2 {
    margin: 0 0 16px;
    font-size: 20px;
    color: var(--text-strong);
}

.stats-grid,
.networks-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.acars-config-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 300px;
}

.acars-config-card h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-strong);
}

.acars-config-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.acars-config-group label {
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-soft);
}

.acars-inline-row,
.acars-api-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.acars-api-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.acars-api-row .api-key-field-wrap {
    flex: 1;
}

.acars-readonly-text {
    flex: 1;
    min-height: 38px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 14px;
    box-sizing: border-box;
}

.icon-only-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: #38bdf8;
    color: #ffffff;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.icon-only-btn:hover {
    background: #0ea5e9;
}

.icon-only-btn:active {
    transform: scale(0.97);
}

.api-key-field-wrap {
    display: flex;
    align-items: stretch;
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
}

.api-key-field-wrap input {
    flex: 1;
    height: 38px !important;
    min-height: 38px !important;
    line-height: 38px;
    padding: 0 12px;
    font-size: 13px;
    border: 1px solid var(--border-color);
    border-right: none;
    border-radius: 10px 0 0 10px;
    background: var(--bg-card);
    color: var(--text-main);
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
}

.api-key-field-wrap input[type="password"],
.api-key-field-wrap input[type="text"] {
    height: 38px !important;
    min-height: 38px !important;
    line-height: 38px;
    padding: 0 12px;
}

.api-key-field-wrap .icon-btn {
    width: 42px;
    min-width: 42px;
    height: 38px;
    min-height: 38px;
    border-radius: 0 10px 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.acars-config-actions {
    margin-top: 4px;
}

.download-config-btn {
    width: 100%;
    min-height: 40px;
    border: none;
    border-radius: 10px;
    background: #38bdf8;
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.download-config-btn:hover {
    background: #0ea5e9;
}

.download-config-btn:active {
    transform: scale(0.98);
}

@media (max-width: 900px) {
    .acars-config-card {
        min-width: 0;
        width: 100%;
    }
}

.network-link {
    text-decoration: none;
    color: inherit;
    transition: transform 0.22s ease, box-shadow 0.22s ease, background-color 0.22s ease;
    cursor: pointer;
}

.network-link:hover {
    text-decoration: none;
    color: inherit;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

body.dark-mode .network-link:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.network-link .stat-value {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.stat-box,
.network-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-soft);
    letter-spacing: 0.04em;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
}

.live-map-card {
    padding-bottom: 16px;
}

.live-embed-wrap {
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}

.live-embed-frame {
    width: 100%;
    height: 640px;
    border: 0;
    display: block;
}

.awards-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.award-item {
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.award-item:hover {
    transform: translateY(-2px);
}

.award-item img {
    max-width: 150px;
    max-height: 150px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: #ffffff;
    padding: 8px;
}

.recent-flights {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.recent-flight-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    text-decoration: none;
    color: inherit;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 16px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.recent-flight-row:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(0,0,0,0.08);
}

.recent-main {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.recent-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-strong);
}

.recent-sub {
    font-size: 13px;
    color: var(--text-soft);
}

.recent-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 13px;
    color: var(--text-main);
    justify-content: flex-end;
}

.empty-block {
    color: var(--text-soft);
    font-size: 14px;
}

.award-modal {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0,0,0,0.45);
}

.award-modal[hidden] {
    display: none !important;
}

.award-modal-box {
    position: relative;
    width: 100%;
    max-width: 680px;
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
    padding: 24px;
}

.award-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    border: none;
    background: transparent;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-main);
}

.award-modal-content {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 18px;
    align-items: start;
}

.award-modal-image {
    max-width: 120px;
    max-height: 120px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background: #ffffff;
    padding: 8px;
}

.award-modal-text h3 {
    margin: 0 0 10px;
    font-size: 22px;
    color: var(--text-strong);
}

.award-modal-text p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-main);
}

@media (max-width: 900px) {
    .grid-two {
        grid-template-columns: 1fr;
    }

    .hero-left {
        flex-direction: column;
        align-items: flex-start;
    }

    .recent-flight-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .recent-meta {
        justify-content: flex-start;
    }

    .award-modal-content {
        grid-template-columns: 1fr;
    }
}