:root {
    --bg-main: #dfe5ec;
    --bg-panel: rgba(255, 255, 255, 0.94);
    --bg-strong: #21405f;
    --bg-accent: #3e6f9f;
    --bg-accent-soft: #d6e2ee;
    --text-main: #243746;
    --text-soft: #647481;
    --border: rgba(33, 64, 95, 0.14);
    --success: #1f8f5f;
    --error: #c73e1d;
    --shadow: 0 20px 50px rgba(33, 64, 95, 0.16);
    --radius-lg: 28px;
    --radius-md: 18px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-main);
    background:
        radial-gradient(circle at top right, rgba(62, 111, 159, 0.18), transparent 28%),
        linear-gradient(135deg, #d7dfe7 0%, #edf2f7 52%, #cfd7e0 100%);
}

body.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.login-shell {
    width: min(460px, 100%);
}

.panel-card,
.card,
.sidebar,
.summary-card {
    backdrop-filter: blur(18px);
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.sidebar h1,
.topbar h2,
.section-head h3,
.panel-card h2 {
    margin: 0;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--bg-accent);
    font-weight: 700;
}

.feature-grid,
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.upload-card,
.user-card,
.pill {
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-panel-centered {
    min-height: calc(100vh - 64px);
}

.panel-card {
    width: 100%;
    padding: 36px;
}

.login-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(236, 241, 246, 0.98));
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 300px 1fr;
}

.sidebar {
    margin: 24px;
    padding: 28px;
    background: linear-gradient(180deg, rgba(33, 64, 95, 0.97), rgba(58, 83, 109, 0.88));
    color: white;
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 24px;
    height: calc(100vh - 48px);
}

.sidebar p,
.sidebar span {
    color: rgba(255, 255, 255, 0.78);
}

.nav-links {
    display: grid;
    gap: 10px;
}

.nav-links a,
.btn {
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.nav-links a {
    color: white;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
}

.nav-links a:hover,
.btn:hover {
    transform: translateY(-1px);
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 14px;
}

.menu-toggle {
    display: none;
    width: 48px;
    height: 48px;
    padding: 10px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.84);
    cursor: pointer;
}

.menu-toggle span {
    display: block;
    width: 100%;
    height: 3px;
    margin: 5px 0;
    border-radius: 999px;
    background: var(--bg-strong);
}

.content {
    padding: 24px 24px 32px 0;
    display: grid;
    align-content: start;
    gap: 20px;
}

.topbar,
.section-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: end;
}

.pill {
    padding: 12px 16px;
    background: var(--bg-accent-soft);
    color: #2a4d73;
    font-weight: 700;
}

.card {
    padding: 28px;
}

.section-head-stack {
    align-items: start;
}

.stack-form {
    display: grid;
    gap: 20px;
}

.inline-field {
    display: flex;
    align-items: end;
}

.grid {
    display: grid;
    gap: 16px;
}

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

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

.col-span-2 {
    grid-column: span 2;
}

label {
    display: grid;
    gap: 8px;
    font-weight: 600;
}

label span {
    color: var(--text-soft);
    font-size: 0.95rem;
}

input,
select,
textarea,
.btn {
    width: 100%;
    border-radius: 14px;
    border: 1px solid var(--border);
    padding: 14px 16px;
    font: inherit;
}

input,
select,
textarea {
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-main);
}

textarea {
    resize: vertical;
}

.upload-card {
    padding: 18px;
    border: 1px dashed rgba(33, 64, 95, 0.24);
    background: linear-gradient(180deg, rgba(62, 111, 159, 0.08), rgba(255, 255, 255, 0.96));
}

.upload-preview {
    width: 100%;
    margin-top: 12px;
    border-radius: 16px;
    max-height: 220px;
    object-fit: cover;
    border: 1px solid rgba(33, 64, 95, 0.16);
}

.upload-preview-visible {
    display: block;
}

.summary-card {
    padding: 22px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.summary-card span {
    display: block;
    color: var(--text-soft);
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.summary-card strong {
    font-size: 1rem;
}

.user-card {
    padding: 18px;
    background: rgba(255, 255, 255, 0.1);
    display: grid;
    gap: 4px;
}

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

.action-card {
    display: grid;
    gap: 10px;
    padding: 24px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--text-main);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(223, 229, 236, 0.92));
    box-shadow: 0 12px 24px rgba(33, 64, 95, 0.08);
}

.action-card strong {
    font-size: 1.06rem;
}

.action-card span {
    color: var(--text-soft);
}

.gps-status {
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(62, 111, 159, 0.08);
    color: var(--bg-strong);
    font-weight: 600;
}

.btn-light {
    background: rgba(62, 111, 159, 0.09);
    color: var(--bg-strong);
    border: 1px solid rgba(33, 64, 95, 0.16);
}

.modal,
.save-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
}

.modal-backdrop,
.save-overlay {
    background: rgba(0, 0, 0, 0.72);
}

.modal-backdrop {
    position: absolute;
    inset: 0;
}

.modal {
    display: grid;
    place-items: center;
    padding: 24px;
}

.modal-card,
.save-card {
    width: min(720px, 100%);
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
    position: relative;
    z-index: 1;
}

.modal-card {
    padding: 24px;
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

.modal-close {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 12px;
    background: rgba(33, 64, 95, 0.08);
    font-size: 1.4rem;
    cursor: pointer;
}

.modal-results {
    display: grid;
    gap: 10px;
    max-height: 360px;
    overflow-y: auto;
}

.result-item,
.result-empty {
    width: 100%;
    text-align: left;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(62, 111, 159, 0.05);
}

.record-list {
    display: grid;
    gap: 14px;
}

.search-row {
    margin-bottom: 18px;
}

.search-label {
    display: grid;
    gap: 8px;
}

.record-item {
    display: grid;
    gap: 6px;
    padding: 18px 20px;
    border-radius: 18px;
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--text-main);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(231, 237, 243, 0.96));
}

.record-item span {
    color: var(--text-soft);
}

.result-item {
    cursor: pointer;
}

.result-item strong,
.result-item span {
    display: block;
}

.result-item span,
.result-empty {
    color: var(--text-soft);
}

.save-overlay {
    display: grid;
    place-items: center;
    padding: 24px;
}

.save-card {
    width: min(420px, 100%);
    padding: 28px;
    text-align: center;
    background: rgba(17, 17, 17, 0.94);
    color: white;
}

.save-card strong {
    display: block;
    font-size: 2rem;
    margin-bottom: 10px;
}

.save-progress-track {
    width: 100%;
    height: 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    overflow: hidden;
    margin-top: 18px;
}

.save-progress-bar {
    width: 0;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(135deg, #5f91c3, #9bc0e8);
    transition: width 0.25s ease;
}

body.modal-open,
body.saving-open {
    overflow: hidden;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 700;
}

.btn-primary {
    background: linear-gradient(135deg, #2f5d8a, #5c7da0);
    color: white;
    border: none;
    box-shadow: 0 16px 24px rgba(47, 93, 138, 0.25);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.14);
    color: white;
}

.btn-block {
    width: 100%;
}

.alert {
    padding: 14px 16px;
    border-radius: 14px;
    font-weight: 600;
}

.alert.success {
    background: rgba(31, 143, 95, 0.14);
    color: var(--success);
}

.alert.error {
    background: rgba(199, 62, 29, 0.12);
    color: var(--error);
}

.hidden {
    display: none !important;
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        top: 16px;
        left: 16px;
        bottom: 16px;
        width: min(320px, calc(100vw - 32px));
        height: auto;
        margin: 0;
        z-index: 20;
        transform: translateX(calc(-100% - 24px));
        transition: transform 0.25s ease;
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
    }

    .content {
        padding: 24px;
    }

    .menu-toggle {
        display: inline-block;
    }

    body.menu-open::before {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(20, 31, 46, 0.35);
        z-index: 10;
    }

    .modal-card,
    .save-card {
        width: 100%;
    }

    .grid-2,
    .grid-3,
    .summary-card,
    .action-grid {
        grid-template-columns: 1fr;
    }

    .col-span-2 {
        grid-column: span 1;
    }
}
