*{box-sizing:border-box}
body{margin:0;background:#0b1020;color:#f4f7ff;font-family:system-ui,sans-serif;display:flex;flex-direction:column;min-height:100vh}

header{height:70px;background:#121a2b;border-bottom:1px solid #293550;padding:0 20px;display:flex;align-items:center;justify-content:space-between;position:sticky;top:0;z-index:100}
.brand{display:flex;gap:10px;align-items:center;font-size:27px}.brand div{display:grid}.brand b{font-size:18px}.brand small{font-size:10px;color:#91a0bc;text-transform:uppercase}

button,input{font:inherit}
button{border:1px solid #293550;background:#182238;color:#fff;border-radius:9px;padding:9px 12px;cursor:pointer;transition:background 0.2s}
button:hover{background:#232f48}

main{display:grid;grid-template-columns:330px 1fr;flex:1}

aside{background:#121a2b;border-right:1px solid #293550;padding:16px;overflow-y:auto;height:calc(100vh - 70px);position:sticky;top:70px}
aside input{width:100%;padding:12px;border-radius:9px;border:1px solid #293550;background:#182238;color:#fff;margin-bottom:10px}
.stats{padding:14px 2px;color:#91a0bc;font-size:12px}.stats b{color:#7cf2c2}
nav{display:flex;gap:6px}
nav .active{border-color:#65a9ff;background:#232f48}

#list{display:grid;gap:7px;margin-top:12px}
.item{background:#182238;border:1px solid #293550;border-radius:10px;padding:11px;cursor:pointer;transition:border 0.2s}
.item.selected{border-color:#65a9ff;background:#1d2944}
.item strong{font-size:13px}.item small{display:block;color:#91a0bc;margin-top:4px}
.dot{display:inline-block;width:8px;height:8px;border-radius:50%;background:#7cf2c2;margin-right:7px}.dot.off{background:#ff7181}
.star{float:right;border:0;background:0;color:#f3d36b;padding:0}

section{padding:20px;max-width:1600px;width:100%;margin:auto}
.card,.panel{background:#121a2b;border:1px solid #293550;border-radius:15px;overflow:hidden}

.head{padding:17px;display:flex;justify-content:space-between;align-items:center}
.head small{color:#65a9ff;font-size:10px}.head h1{font-size:20px;margin:4px 0}.head p{color:#91a0bc;font-size:12px;margin:0}

/* TÄÄLLÄ OLIPAIKKAAN VIKAA: Muutettu kiinteästä 540px -> joustavaan korkeuteen */
#viewer{
    height: 60vh; /* Käyttää 60% näytön korkeudesta */
    min-height: 300px;
    max-height: 600px;
    background:#050810;
    display:flex;
    align-items:center;
    justify-content:center;
}
.empty{text-align:center;color:#91a0bc;font-size:40px}.empty b{display:block;font-size:14px;color:#fff}
#viewer img{width:100%;height:100%;object-fit:contain}

.foot{padding:10px 17px;color:#91a0bc;font-size:11px;display:flex;justify-content:space-between}

/* Ruudukko: Kartta ja tiedot */
.grid{display:grid;grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));gap:15px;margin-top:15px}
.panel{padding:17px}
.panel h2{font-size:15px;margin:0}

#map{
    height:260px;
    margin-top:13px;
    border:1px solid #293550;
    border-radius:11px;
    position:relative;
    overflow:hidden;
    background-color:#111b2e;
    background-image:linear-gradient(rgba(255,255,255,.06) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,.06) 1px,transparent 1px);
    background-size:28px 28px
}
.marker{position:absolute;width:12px;height:12px;border-radius:50%;border:2px solid white;background:#65a9ff;transform:translate(-50%,-50%);cursor:pointer;transition: scale 0.2s}
.marker:hover{scale: 1.3}
.marker.sel{width:20px;height:20px;background:#7cf2c2}.marker.off{background:#ff7181}

dl{margin:10px 0}
dl div{display:flex;justify-content:space-between;border-bottom:1px solid #293550;padding:10px 0;gap:15px}
dt{color:#91a0bc}dd{margin:0;text-align:right}

footer{text-align:center;padding:12px;color:#91a0bc;font-size:10px;border-top:1px solid #293550}

/* Responsiivisuus */
@media(max-width:1100px){
    main{grid-template-columns: 260px 1fr}
}
@media(max-width:900px){
    main{grid-template-columns:1fr}
    aside{max-height:none;height:auto;position:static;border-right:0;border-bottom:1px solid #293550}
    .grid{grid-template-columns:1fr}
    #viewer{height:400px}
}
@media(max-width:600px){
    section{padding:10px}
    #viewer{height:300px}
}
/* Kartan koko */
#map {
    height: 300px; 
    width: 100%;
    border-radius: 11px;
    margin-top: 13px;
}

/* Reitit-osio */
.routes-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #293550;
}
.routes-section h3 {
    font-size: 13px;
    color: #91a0bc;
    margin-bottom: 10px;
}
.route-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #182238;
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 5px;
    font-size: 12px;
}
.route-item button {
    padding: 3px 6px;
    font-size: 10px;
}
#add-route {
    width: 100%;
    margin-top: 10px;
    font-size: 12px;
    border-style: dashed;
}
