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

:root {
    --primary: #0EA5A4;
    --success: #10B981;
    --warning: #F59E0B;
    --danger:  #EF4444;
    --bg:      #F8FAFC;
    --card:    #FFFFFF;
    --text:    #1E293B;
    --muted:   #64748B;
    --border:  #E2E8F0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* --- Login --- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0EA5A4 0%, #134E4A 100%);
    padding: 20px;
}
.login-card {
    background: var(--card);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .2);
    width: 100%;
    max-width: 400px;
}
.brand-head {
    text-align: center;
    margin-bottom: 28px;
}
.brand-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 12px;
    filter: drop-shadow(0 4px 12px rgba(14, 165, 164, 0.25));
}
.login-card h1 {
    font-size: 28px;
    margin-bottom: 8px;
    color: var(--primary);
    text-align: center;
}
.brand-head .subtitle {
    text-align: center;
}
.login-card .subtitle {
    color: var(--muted);
    margin-bottom: 32px;
    font-size: 14px;
}

.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--muted);
}
.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    transition: border-color .15s;
}
.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.btn {
    display: inline-block;
    width: 100%;
    padding: 12px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s;
}
.btn:hover { opacity: .9; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-error { background: #FEE2E2; color: #991B1B; }
.alert-info  { background: #DBEAFE; color: #1E3A8A; }

.hint {
    margin-top: 20px;
    padding: 12px;
    background: #F1F5F9;
    border-radius: 8px;
    font-size: 12px;
    color: var(--muted);
}
.hint code { background: #E2E8F0; padding: 2px 6px; border-radius: 3px; font-family: 'JetBrains Mono', Consolas, monospace; }

/* --- Topbar --- */
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,.04);
}
.topbar .brand {
    font-weight: 700;
    color: var(--primary);
    font-size: 18px;
    text-decoration: none;
}
/* Haritaya dönüş pill butonu (admin, station, super, map) */
.topbar .nav-home {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #06b6d4 0%, #0ea5e9 100%);
    color: #fff;
    border-radius: 999px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(6, 182, 212, 0.35);
    transition: transform .15s, box-shadow .15s, filter .15s;
}
.topbar .nav-home:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
    box-shadow: 0 4px 14px rgba(6, 182, 212, 0.5);
}
.topbar .nav-home:active { transform: translateY(0); }
.topbar .nav-home svg { width: 18px; height: 18px; flex-shrink: 0; }
.topbar .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    /* Telefonda nav butonları sayfayı yatay olarak itiyordu: 375px ekranda
       içerik 661px'e çıkıyor, kullanıcı alarm kartlarını okurken sayfa
       sağa kayıyordu. Artık taşma şeridin KENDİ İÇİNDE kalıyor. */
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.topbar .user-info::-webkit-scrollbar { display: none; }
.topbar .user-info > * { flex: none; }
.topbar .user-info .name { font-weight: 600; }
.topbar .user-info .role {
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    text-transform: uppercase;
}

/* --- Map --- */
#map {
    height: calc(100vh - 60px);
    width: 100%;
}

/* --- Zenginleştirilmiş Pin --- */
.pin-divicon { background: transparent !important; border: none !important; }
.pin-wrap {
    position: relative;
    width: 36px;
    height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.35));
    transition: transform .15s;
}
.pin-wrap:hover { transform: translateY(-3px) scale(1.08); }
.pin-body {
    width: 30px; height: 30px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 3px solid white;
    display: flex; align-items: center; justify-content: center;
    position: relative;
}
.pin-body .pin-icon {
    transform: rotate(45deg);
    color: white;
    font-weight: 900;
    font-size: 14px;
    line-height: 1;
}
.pin-ok      { background: #10B981; }
.pin-warning { background: #F59E0B; }
.pin-alarm   { background: #EF4444; }
.pin-offline { background: #64748B; }
/* Y5 — veri bayat: son başarılı okuma eşikten eski (map.html BAYAT_S) */
.pin-stale .pin-body { opacity: .5; outline: 2px dashed #94A3B8; outline-offset: 2px; }
.pin-stale-badge {
    position: absolute; top: -8px; left: -10px; z-index: 10;
    width: 20px; height: 20px; border-radius: 50%;
    background: #334155; color: #fff; font-size: 11px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff;
}
.pin-tooltip .tt-stale { color: #B45309; font-size: 11px; font-weight: 600; margin-top: 2px; }

.pin-code {
    margin-top: 2px;
    background: rgba(255,255,255,0.92);
    color: #1E293B;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 3px;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0,0,0,.2);
    letter-spacing: .3px;
}

.pin-pulse::before {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 30px; height: 30px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.55);
    animation: pinPulse 1.6s infinite ease-out;
    z-index: -1;
}
@keyframes pinPulse {
    0%   { transform: scale(1);   opacity: .7; }
    70%  { transform: scale(2.2); opacity: 0; }
    100% { transform: scale(2.2); opacity: 0; }
}

/* --- Tooltip (hover) --- */
.pin-tooltip { font-size: 12px; line-height: 1.5; min-width: 160px; }
.pin-tooltip b { display: block; margin-bottom: 4px; font-size: 13px; }
.pin-tooltip .tt-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}
.pin-tooltip .tt-muted { color: #94A3B8; font-size: 11px; margin-top: 2px; }

/* --- Zenginleştirilmiş Popup --- */
.popup-card { min-width: 240px; }
.popup-card .popup-head {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.popup-card .popup-badge {
    width: 32px; height: 32px;
    border-radius: 50%;
    color: white;
    font-weight: 900;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.popup-card h3 { margin: 0 0 2px 0; font-size: 15px; color: var(--text); }
.popup-card .popup-code { font-size: 11px; color: var(--muted); font-family: Consolas, monospace; }

.popup-grid { margin-bottom: 10px; }
.popup-row {
    display: flex; justify-content: space-between;
    padding: 4px 0;
    font-size: 12px;
    border-bottom: 1px dashed #F1F5F9;
}
.popup-row:last-child { border: none; }
.popup-row span { color: var(--muted); }
.popup-row b { color: var(--text); }

.popup-desc {
    font-size: 12px; color: var(--muted);
    padding: 8px; background: #F8FAFC;
    border-radius: 6px; margin-bottom: 10px;
    border-left: 3px solid var(--primary);
}
.popup-actions { display: flex; gap: 6px; }
.popup-actions .btn { flex: 1; text-decoration: none; text-align: center; }
.btn-sm { padding: 7px 10px; font-size: 12px; width: auto; }

/* --- Harita Legendası --- */
.map-legend {
    background: rgba(255,255,255,0.97);
    padding: 10px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,.15);
    font-size: 12px;
    min-width: 170px;
    backdrop-filter: blur(6px);
}
.legend-title {
    font-weight: 700;
    color: var(--text);
    font-size: 12px;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.legend-items { display: flex; flex-direction: column; gap: 2px; }
.legend-item {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: background .15s;
}
.legend-item:hover { background: #F1F5F9; }
.legend-item.active {
    background: var(--primary);
    color: white;
}
.legend-item.active .legend-count { background: rgba(255,255,255,0.25); color: white; }
.legend-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 0 1px rgba(0,0,0,.1);
}
.legend-label { flex: 1; }
.legend-count {
    background: #E2E8F0;
    color: var(--text);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    min-width: 22px;
    text-align: center;
}
.legend-footer {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 11px;
    text-align: center;
}
.legend-footer a { color: var(--primary); text-decoration: none; font-weight: 600; }

/* --- Pin Risk Rozeti --- */
.pin-risk-badge {
    position: absolute;
    top: -8px; right: -10px;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: #EF4444;
    color: white;
    font-size: 12px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0,0,0,.4);
    z-index: 10;
}
.pin-risk-pulse {
    animation: riskPulse 1.4s infinite;
}
@keyframes riskPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 2px 6px rgba(239,68,68,.8); }
    50%      { transform: scale(1.15); box-shadow: 0 0 14px rgba(239,68,68,1); }
}

/* --- Popup Hava Durumu Bölümü --- */
.popup-weather {
    margin: 10px 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.pw-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 10px;
    color: white;
    font-size: 12px; font-weight: 700;
}
.pw-max { font-size: 11px; opacity: .9; }
.pw-now {
    padding: 6px 10px;
    background: #F8FAFC;
    font-size: 11px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}
.pw-chart {
    display: flex; align-items: flex-end;
    height: 60px; padding: 4px 8px;
    gap: 2px;
    background: white;
}
.pw-bar {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: flex-end;
    height: 100%;
    position: relative;
    cursor: default;
}
.pw-bar-fill {
    width: 100%;
    min-height: 2px;
    background: #60A5FA;
    border-radius: 2px 2px 0 0;
    transition: height .3s;
}
.pw-bar-lbl {
    font-size: 8px;
    color: var(--muted);
    margin-top: 2px;
}
.pw-hint {
    padding: 4px 8px;
    font-size: 10px;
    color: var(--muted);
    background: #F8FAFC;
    text-align: right;
    font-style: italic;
}

/* --- Hava Durumu Paneli (wx-ctrl) --- */
.wx-ctrl {
    background: rgba(255,255,255,0.97);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,.15);
    font-size: 12px;
    min-width: 240px;
    max-width: 280px;
    backdrop-filter: blur(6px);
    overflow: hidden;
}
.wx-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 10px;
    cursor: pointer;
    user-select: none;
    background: linear-gradient(to right, #0EA5A4, #134E4A);
    color: white;
    font-weight: 700;
}
.wx-chevron { font-size: 10px; }
.wx-body {
    padding: 8px 10px;
}
.wx-layer {
    display: flex; align-items: center; gap: 6px;
    padding: 5px 2px;
    cursor: pointer;
    border-radius: 4px;
    user-select: none;
}
.wx-layer:hover { background: #F1F5F9; }
.wx-layer input[type=checkbox]:disabled + .wx-icon { opacity: .4; }
.wx-layer input[type=checkbox]:disabled ~ span:not(.wx-need-key) { opacity: .4; }
.wx-icon { font-size: 15px; width: 20px; text-align: center; }
.wx-need-key {
    margin-left: auto;
    font-size: 9px;
    color: #EF4444;
    font-style: italic;
}

.wx-section {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}
.wx-time {
    font-weight: 700;
    font-size: 13px;
    color: var(--primary);
    text-align: center;
    margin-bottom: 6px;
}
.wx-time.wx-forecast { color: #F59E0B; }
.wx-time .wx-rel { font-size: 10px; font-weight: 500; opacity: .8; }
.wx-time .wx-hint { font-size: 10px; color: var(--muted); font-weight: 500; }
.wx-slider { width: 100%; accent-color: var(--primary); }

.wx-timeline {
    display: flex;
    height: 4px;
    margin: 4px 0;
    border-radius: 2px;
    overflow: hidden;
}
.tl-past   { background: #CBD5E1; min-height: 4px; }
.tl-now    { background: #10B981; width: 4px; min-height: 4px; }
.tl-future { background: #FDE68A; min-height: 4px; }

.wx-btns {
    display: flex; align-items: center; gap: 4px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.wx-btns button {
    background: var(--primary); color: white;
    border: none; border-radius: 4px;
    padding: 4px 8px; font-size: 11px;
    cursor: pointer; font-weight: 600;
}
.wx-btns button:hover { opacity: .85; }
.wx-legend {
    display: flex; align-items: center; gap: 3px;
    font-size: 10px;
    color: var(--muted);
    margin-left: auto;
}
.wx-legend i {
    display: inline-block;
    width: 9px; height: 9px;
    border-radius: 2px;
    margin-left: 3px;
}

.wx-risk {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}
.wx-risk-title {
    font-weight: 700;
    font-size: 11px;
    margin-bottom: 6px;
    color: var(--text);
}
.wx-risk-row {
    display: flex; justify-content: space-between;
    padding: 4px 6px;
    margin: 3px 0;
    border-left: 3px solid;
    background: #F8FAFC;
    border-radius: 3px;
    font-size: 11px;
}
.wx-risk-row b { font-weight: 600; }
.wx-mm { color: var(--muted); font-weight: 600; }
.wx-risk-none {
    color: #10B981;
    text-align: center;
    padding: 6px;
    font-size: 11px;
    font-weight: 600;
}

/* Eski --radar-ctrl stilini koruyoruz (yedek) */
.radar-ctrl {
    background: rgba(255,255,255,0.97);
    padding: 8px 10px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,.15);
    font-size: 12px;
    min-width: 220px;
    backdrop-filter: blur(6px);
}
.radar-toggle {
    display: flex; align-items: center; gap: 6px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text);
    user-select: none;
}
.radar-toggle input { cursor: pointer; }
.radar-body {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}
.radar-time {
    font-weight: 700;
    font-size: 13px;
    color: var(--primary);
    text-align: center;
    margin-bottom: 6px;
}
.radar-btns {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 6px;
}
.radar-btns button {
    background: var(--primary); color: white;
    border: none; border-radius: 4px;
    padding: 4px 10px; font-size: 11px;
    cursor: pointer; font-weight: 600;
}
.radar-btns button:hover { opacity: .85; }
.radar-legend {
    display: flex; align-items: center; gap: 3px;
    font-size: 10px;
    color: var(--muted);
}
.radar-legend i {
    display: inline-block;
    width: 9px; height: 9px;
    border-radius: 2px;
    margin-left: 3px;
}

/* --- Station Viewer --- */
.station-wrap {
    height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
}
.station-header {
    background: var(--card);
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.station-header h2 { font-size: 16px; }
.station-header .status {
    display: inline-block;
    width: 10px; height: 10px; border-radius: 50%;
    margin-right: 6px;
}
.vnc-container {
    flex: 1;
    background: #000;
    position: relative;
    overflow: hidden;
}
#vnc-screen { width: 100%; height: 100%; }

.vnc-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.8);
    color: white;
    font-size: 15px;
    z-index: 10;
}
.vnc-overlay.hidden { display: none; }
.spinner {
    border: 3px solid rgba(255,255,255,.2);
    border-top-color: white;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    animation: spin 1s linear infinite;
    margin-right: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Station Body Split (VNC + Camera) --- */
.station-body {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
}
.station-body .vnc-container { flex: 1 1 auto; min-width: 0; }
.camera-container {
    width: 420px;
    max-width: 45vw;
    display: flex;
    flex-direction: column;
    background: #0b0f14;
    border-left: 1px solid var(--border);
}
.camera-header {
    background: var(--card);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text);
}
.camera-view {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #000;
}
.camera-view img, .camera-view video, .camera-view iframe {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border: 0;
    background: #000;
}
.camera-loading, .camera-error {
    color: #cbd5e1;
    font-size: 13px;
    padding: 12px;
    text-align: center;
}
.camera-error { color: #fca5a5; }

@media (max-width: 900px) {
    .station-body { flex-direction: column; }
    .camera-container { width: 100%; max-width: none; height: 40vh; border-left: 0; border-top: 1px solid var(--border); }
}
