:root {
    --bg-dark: #121212;
    --bg-panel: #1e1e1e;
    --primary: #ffaa00;
    --success: #00e676;
    --danger: #ff5252;
    --text-main: #e0e0e0;
    --text-muted: #aaaaaa;
    --accent: #00e5ff;
}

body { 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    background: var(--bg-dark); 
    color: var(--text-main); 
    margin: 0; 
    padding: 20px;
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    min-height: 100vh;
}

.container { max-width: 1100px; width: 100%; }
.hidden { display: none !important; }


.row { 
    display: flex; 
    gap: 20px; 
    margin-bottom: 20px; 
    flex-wrap: wrap;
    align-items: stretch; 
}

.col { 
    flex: 1; 
    min-width: 300px; 
    display: flex; 
    flex-direction: column; 
}


.header-section { text-align: center; margin-bottom: 40px; }
h1 { color: var(--primary); margin: 0; font-size: 2.5rem; letter-spacing: 1px; }
.subtitle { color: var(--text-muted); margin-top: 5px; }
.mission-badge { 
    display: inline-block; 
    padding: 5px 15px; 
    border-radius: 15px; 
    background: #333; 
    color: #fff; 
    font-size: 0.9rem; 
    margin-top: 0px;
    text-transform: uppercase; 
    font-weight: bold;
    letter-spacing: 1px;
}

.drop-zone { 
    border: 2px dashed #444; 
    border-radius: 12px; 
    padding: 40px; 
    text-align: center; 
    transition: 0.3s; 
    cursor: pointer; 
    background: var(--bg-panel);
    margin: 20px auto;
    max-width: 600px;
}
.drop-zone:hover { border-color: var(--primary); background: #252525; }
.drop-zone.dragover { border-color: var(--success); background: #2a3a2a; }
.status-text { font-family: monospace; color: var(--success); margin-top: 10px; min-height: 20px; }

.panel { 
    background: var(--bg-panel); 
    border-radius: 12px; 
    padding: 20px; 
    box-shadow: 0 4px 20px rgba(0,0,0,0.3); 
    border: 1px solid #333; 
    
    
    flex: 1;
    display: flex; 
    flex-direction: column;
    box-sizing: border-box; 
}
.panel-title { font-size: 1.1rem; color: var(--text-muted); margin-bottom: 15px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid #333; padding-bottom: 10px; }
.panel-desc { font-size: 0.85rem; color: #888; margin-top: -10px; margin-bottom: 15px; line-height: 1.4; }


.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); 
    gap: 15px;
    margin-bottom: 20px;
}

@media (max-width: 980px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
    .kpi-grid { grid-template-columns: 1fr; }
}

.kpi-card { background: #252525; padding: 20px; border-radius: 8px; text-align: center; border-left: 4px solid var(--primary); position: relative; }
.kpi-value { font-size: 2.2rem; font-weight: bold; margin: 5px 0; }
.kpi-label { color: var(--text-muted); font-size: 0.85rem; font-weight: bold; text-transform: uppercase; }
.kpi-sub { font-size: 0.8rem; opacity: 0.8; color: var(--accent); }
.kpi-input-row { margin-top: 12px; border-top: 1px solid #444; padding-top: 10px; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.kpi-input-row label { font-size: 0.75rem; color: #bbbbbb; letter-spacing: 0.5px; text-transform: uppercase; }
.kpi-input-row input { background: #333; border: 1px solid #555; color: #fff; padding: 6px; border-radius: 4px; text-align: center; font-weight: bold; }


table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-top: 5px; }
th { text-align: left; color: #888; border-bottom: 1px solid #333; padding: 5px; }
td { padding: 8px 5px; border-bottom: 1px solid #222; }
tr:last-child td { border-bottom: none; }


.cumulative-list { list-style: none; padding: 0; margin: 0; }
.cumulative-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #333; font-size: 0.9rem; }
.cumulative-list li:last-child { border: none; }


.bar-container { margin-bottom: 8px; display: flex; align-items: center; font-size: 0.9rem; }
.bar-label { width: 60px; font-family: monospace; color: var(--text-muted); }
.bar-track { flex-grow: 1; background: #333; height: 16px; border-radius: 4px; overflow: hidden; margin: 0 10px; }
.bar-fill { height: 100%; background: var(--primary); width: 0%; transition: width 0.5s ease; }
.bar-value { width: 45px; text-align: right; font-weight: bold; }


.wave-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.wave-box { 
    aspect-ratio: 1; 
    background: #333; 
    border-radius: 4px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 0.8rem; 
    font-weight: bold; 
    color: #121212; 
    cursor: default; 
    position: relative;
}
.wave-box:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
    border: 1px solid #555;
}
.wave-fast { background: var(--success); }
.wave-slow { background: var(--danger); }

.btn { padding: 12px 24px; border: none; border-radius: 6px; font-weight: bold; cursor: pointer; font-size: 1rem; background: var(--primary); color: #121212; margin-top: 20px;}
.btn:hover { background: #ffcc00; transform: translateY(-2px); transition: 0.2s; }
.spinner { border: 4px solid #333; border-top: 4px solid var(--primary); border-radius: 50%; width: 30px; height: 30px; animation: spin 1s linear infinite; margin: 20px auto; display: none; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.upload-hint {
  margin-top: 12px;
  text-align: center;
  display: inline-block;
  background: rgba(0,229,255,0.06); 
  border: 1px solid rgba(0,229,255,0.12);
  color: #bde7ff; 
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.92rem;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}


input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}
input[type=number] {
  appearance: textfield;      
  -moz-appearance: textfield; 
}


.results-section .action-buttons,
#resultsSection > div:last-child {
        display: flex;
        justify-content: center;
        gap: 15px;
        margin-top: 20px;
}


#actionButtons { display:flex; justify-content:center; gap:12px; align-items:center; width:100%; }


#packList {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#packList svg {
    flex: 1;
    min-height: 0;
}

#slowestList,
#waveGrid,
#saturationBars {
    flex: 1;
    min-height: 0;
}


table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-top: 5px;
    flex: 1;
}


.panel > *:not(.panel-title):not(.panel-desc) {
    min-height: 0;
}

.panel > div:has(> ul),
.panel > ul {
    flex: 1;
    min-height: 0;
}


.leaderboard-panel .table-wrapper {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 700px) {
    h1 { font-size: 1.4rem; }
    .subtitle { font-size: 0.9rem; }
    .panel { padding: 12px; }

    
    div[style*="margin-bottom: -30px"] {
        margin-bottom: 20px !important;
    }

    
    .leaderboard-panel { max-height: calc(100vh - 140px); overflow: auto; }

    
    .leaderboard-panel .table-wrapper { max-height: calc(100vh - 180px); }

    
    .leaderboard-panel table thead { display: none; }
    .leaderboard-panel table, .leaderboard-panel tbody, .leaderboard-panel tr { display: block; width: 100%; }
    .leaderboard-panel tr { margin: 0 0 12px 0; padding: 10px; background: #1a1a1a; border-radius: 8px; }
    .leaderboard-panel td { display: flex; justify-content: space-between; padding: 6px 8px; border: none; }
    .leaderboard-panel td:first-child { color: var(--primary); font-weight: bold; }
    .leaderboard-panel td:nth-child(2) { font-weight: bold; color: var(--text-main); }
    .leaderboard-panel td:nth-child(3) { color: var(--text-muted); font-size: 0.95rem; }
    .leaderboard-panel td:nth-child(4) { text-align: right; color: var(--primary); font-weight: bold; }
}

.rank-cell { display: inline-flex; align-items: center; gap: 8px; }
.rank-current { line-height: 1; }
.rank-ghost {
  font-size: 0.65rem;
  opacity: 0.7;
  background: rgba(255,255,255,0.02);
  padding: 2px 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transform-origin: center;
}
.rank-ghost .arrow { font-weight: 700; font-size: 0.78rem; transform: translateY(-1px); color: inherit; }


@media (max-width: 700px) {
  .leaderboard-panel td:first-child .rank-ghost { margin-left: 8px; font-size: 0.78rem; opacity: 0.7; }
}
