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

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    min-height: 100vh;
    padding-bottom: 80px;
}

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

h1 { font-size: 1.5rem; color: #38bdf8; margin-bottom: 1.5rem; }
h2 { color: #94a3b8; font-size: 0.95rem; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 1rem; }

.card {
    background: #1e293b;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h2 {
    color: #94a3b8;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
}

.stat-card {
    background: #0f172a;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}

.stat-card .label { color: #64748b; font-size: 0.75rem; text-transform: uppercase; }
.stat-card .value { color: #f1f5f9; font-size: 1.8rem; font-weight: bold; margin-top: 0.3rem; }
.stat-card .value.gold { color: #fbbf24; }
.stat-card .sub { color: #94a3b8; font-size: 0.8rem; margin-top: 0.2rem; }

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    color: #64748b;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid #334155;
}

td {
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid #1e293b;
    font-size: 0.9rem;
    vertical-align: middle;
}

tr:hover td { background: #263548; }

a { color: #38bdf8; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Bottom Nav ── */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1e293b;
    border-top: 1px solid #334155;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0.5rem 0;
    z-index: 100;
    max-width: 1000px;
    margin: 0 auto;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 16px 16px 0 0;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.35rem 0.6rem;
    color: #64748b;
    text-decoration: none;
    font-size: 0.65rem;
    transition: color 0.2s;
    border: none;
    background: none;
    cursor: pointer;
    min-width: 60px;
}

.nav-item:hover { color: #e2e8f0; text-decoration: none; }
.nav-item.active { color: #38bdf8; }

.nav-item .nav-icon {
    font-size: 1.4rem;
    line-height: 1;
}

/* ── Buttons ── */

.btn {
    display: inline-block;
    background: #2563eb;
    color: white;
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
}
.btn:hover { background: #1d4ed8; text-decoration: none; }
.btn:disabled { background: #475569; cursor: not-allowed; }
.btn.small { padding: 0.35rem 0.8rem; font-size: 0.8rem; }
.btn.danger { background: #dc2626; }
.btn.danger:hover { background: #b91c1c; }
.btn-secondary {
    background: transparent;
    color: #38bdf8;
    border: 1px solid #334155;
    padding: 0.5rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-secondary:hover { background: #1e3a5f; border-color: #38bdf8; text-decoration: none; }

/* ── Forms ── */

.form-row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: end; }
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field label { color: #94a3b8; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; }

.field input, .field select {
    background: #0f172a;
    color: #e2e8f0;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

.field input:focus, .field select:focus {
    border-color: #38bdf8;
    outline: none;
}

/* ── Badges ── */

.badge {
    background: #334155;
    color: #94a3b8;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
}
.badge.fast { background: #166534; color: #86efac; }
.badge.medium { background: #854d0e; color: #fde047; }
.badge.slow { background: #7f1d1d; color: #fca5a5; }
.badge.db12 { background: #166534; color: #86efac; }
.badge.db22 { background: #7e2d0e; color: #fde047; }
.badge.info { background: #1e3a5f; color: #38bdf8; }

/* ── Rankings ── */

.rank { color: #64748b; font-weight: bold; width: 30px; }
.rank.gold { color: #fbbf24; }
.rank.silver { color: #94a3b8; }
.rank.bronze { color: #c0845c; }

/* ── Stats grid ── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

/* ── Warnings ── */

.warning-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
}
.warning-badge.danger {
    background: #7f1d1d;
    color: #fca5a5;
}
.warning-badge.warning {
    background: #713f12;
    color: #fde68a;
}

/* ── Misc ── */

.back-link { color: #38bdf8; text-decoration: none; font-size: 0.9rem; display: inline-block; margin-bottom: 1rem; }
.back-link:hover { text-decoration: underline; }

.page-title { font-size: 1.5rem; color: #38bdf8; margin-bottom: 0.3rem; }
.page-meta { color: #94a3b8; margin-bottom: 1.5rem; font-size: 0.9rem; }

.photo-circle {
    width: 40px; height: 40px; border-radius: 50%;
    object-fit: cover; background: #334155;
}
.photo-placeholder {
    width: 40px; height: 40px; border-radius: 50%;
    background: #334155; display: flex;
    align-items: center; justify-content: center;
    color: #64748b; font-size: 1rem;
}

/* ── Upload zone ── */

.upload-zone {
    border: 2px dashed #334155;
    border-radius: 12px;
    padding: 3rem 1.5rem;
    text-align: center;
    transition: all 0.3s;
    background: #1e293b;
    cursor: pointer;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: #38bdf8;
    background: #1e3a5f;
}

.upload-zone input[type="file"] { display: none; }
.upload-icon { font-size: 3rem; margin-bottom: 1rem; }
.upload-text { color: #94a3b8; font-size: 1.1rem; }
.upload-text strong { color: #38bdf8; }

/* ── Session card ── */

.session-card {
    background: #1e293b;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
    gap: 1rem;
    flex-wrap: wrap;
}

.session-card:hover { background: #263548; }

.session-info h3 { color: #e2e8f0; font-size: 0.95rem; }
.session-info p { color: #64748b; font-size: 0.85rem; }

.session-link { color: #38bdf8; text-decoration: none; font-size: 0.9rem; white-space: nowrap; }
.session-link:hover { text-decoration: underline; }

.badges-row { display: flex; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; }

/* ── Filters ── */

.filters {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: end;
    margin-bottom: 1.5rem;
}

.filters select, .filters input {
    background: #0f172a;
    color: #e2e8f0;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
}

.filters select:focus, .filters input:focus {
    border-color: #38bdf8;
    outline: none;
}

/* ── Informes actions ── */

.action-card {
    background: #1e293b;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    text-align: center;
    transition: background 0.2s;
    cursor: pointer;
}

.action-card:hover { background: #263548; }

.action-card .action-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.action-card h3 { color: #e2e8f0; font-size: 1.1rem; margin-bottom: 0.3rem; }
.action-card p { color: #64748b; font-size: 0.85rem; }

/* ── Config sub-sections ── */

.config-list { list-style: none; }
.config-list li {
    padding: 1rem;
    border-bottom: 1px solid #334155;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.config-list li:last-child { border-bottom: none; }
.config-list li:hover { background: #263548; }

.config-list .config-name { color: #e2e8f0; font-weight: bold; }
.config-list .config-meta { color: #64748b; font-size: 0.8rem; }

/* ── Test metrics ── */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.metric {
    background: #0f172a;
    border-radius: 8px;
    padding: 0.85rem;
    text-align: center;
}

.metric-label { color: #64748b; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; }
.metric-value { color: #f1f5f9; font-size: 1.3rem; font-weight: bold; margin-top: 0.2rem; }
.metric-unit { color: #94a3b8; font-size: 0.7rem; }

.big-time { font-size: 2rem; font-weight: bold; color: #38bdf8; }

.chart-container { text-align: center; margin: 1.5rem 0; }
.chart-container img { max-width: 100%; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }

/* ── Loading spinner ── */

.loading { display: none; text-align: center; padding: 2rem; }
.loading.active { display: block; }

.spinner {
    border: 3px solid #334155;
    border-top: 3px solid #38bdf8;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* ── Error ── */

.error {
    background: #7f1d1d;
    border: 1px solid #dc2626;
    color: #fca5a5;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

/* ── Boat layout ── */

.layout { display: flex; gap: 2rem; flex-wrap: wrap; }
.boat-panel { flex: 1; min-width: 340px; }
.form-panel { flex: 1; min-width: 300px; }

.pos-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
    padding: 0.4rem 0;
}

.pos-label { width: 90px; font-size: 0.8rem; color: #64748b; text-align: right; flex-shrink: 0; }
.pos-label.tambor { color: #dc2626; }
.pos-label.timonel { color: #16a34a; }
.pos-label.estribor { color: #d97706; }
.pos-label.babor { color: #0ea5e9; }

.pos-select { flex: 1; }
.pos-select select {
    width: 100%;
    background: #0f172a;
    color: #e2e8f0;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
}

.section-label {
    color: #475569;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 1rem 0 0.5rem;
    border-top: 1px solid #334155;
    padding-top: 0.75rem;
}

/* ── Edit inline ── */

.edit-inline { cursor: pointer; }
.edit-inline:hover { opacity: 0.8; }

.edit-form { display: none; margin-top: 0.5rem; }
.edit-form.visible { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* ── Chart expanded mode ── */

.card.expanded {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    max-width: none;
    margin: 0;
    border-radius: 0;
    overflow-y: auto;
    padding: 1rem;
    background: #0f172a;
}

.card.expanded #chart-plotly-container {
    height: calc(100vh - 120px);
}

.card.expanded #chart-plotly-container iframe {
    height: 100%;
}

.card.expanded #chart-png-container {
    max-height: calc(100vh - 120px);
    overflow: auto;
}

.card.expanded #chart-png-container img {
    max-height: calc(100vh - 120px);
    object-fit: contain;
}

.card.expanded .chart-toggle-bar {
    position: sticky;
    top: 0;
    background: #0f172a;
    padding: 0.5rem 0;
    z-index: 10;
}

body.no-scroll {
    overflow: hidden;
}
