.sncft-v5-root { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 
    margin: 16px auto; 
    color: #0f172a; 
    background: #f1f5f9; 
    padding: 12px; 
    border-radius: 24px;
    box-sizing: border-box;
    isolation: isolate;
    max-width: 100%;
}
.sncft-v5-root * { box-sizing: border-box; }
.sncft-v5-root.rtl { direction: rtl; text-align: right; }

/* --- COCKPIT HEADER --- */
.sncft-v5-cockpit { 
    background: #ffffff; 
    border: 1px solid #e2e8f0; 
    border-radius: 20px; 
    padding: 16px; 
    margin-bottom: 12px; 
    box-shadow: 0 10px 25px -5px rgba(0, 51, 102, 0.05);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sncft-v5-topbar { 
    display: flex; 
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 14px;
    margin-bottom: 2px;
    gap: 10px;
}

.sncft-v5-brand { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.sncft-v5-title { font-size: 24px; font-weight: 900; color: #002b5c; margin: 0; display: flex; align-items: center; gap: 8px; letter-spacing: -0.5px; }

.sncft-v5-refresh-btn {
    background: #0070f3 !important;
    border: none !important;
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer;
    transition: transform 0.4s ease;
    color: #ffffff !important;
    font-size: 18px !important;
    padding: 0 !important;
    box-shadow: 0 4px 10px rgba(0, 112, 243, 0.3);
}
.sncft-v5-refresh-btn:active { transform: scale(0.92); }
.sncft-v5-refresh-btn.rotating { animation: sncft-v5-spin 0.8s linear infinite; }

.sncft-v5-live-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 800; color: #16a34a; background: #bbf7d0; padding: 2px 8px; border-radius: 30px; }
.sncft-v5-pulse { width: 6px; height: 6px; background: #16a34a; border-radius: 50%; animation: sncft-v5-pulse-anim 1.8s infinite; }
.sncft-v5-meta-time { font-size: 12px; color: #64748b; font-weight: 600; }

/* --- FILTERS & SEARCH ROW --- */
.sncft-v5-filter-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.sncft-v5-search-box { position: relative; width: 100%; }
.sncft-v5-search-input {
    width: 100%;
    height: 46px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    padding: 0 16px;
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
    outline: none;
    transition: all 0.2s ease;
}
.sncft-v5-search-input:focus {
    background: #ffffff;
    border-color: #0070f3;
    box-shadow: 0 0 0 3px rgba(0, 112, 243, 0.15);
}

.sncft-v5-segmented { 
    position: relative;
    background: #0070f3; 
    padding: 4px; 
    border-radius: 14px; 
    display: flex;
    width: 100%;
    height: 48px;
    align-items: center;
    overflow: hidden;
}

.sncft-v5-pill {
    position: absolute;
    top: 4px;
    left: 4px;
    width: calc(50% - 4px);
    height: calc(100% - 8px);
    background: #ffffff; 
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    z-index: 1;
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.sncft-v5-segmented.pos-gl .sncft-v5-pill { transform: translateX(0); }
.sncft-v5-segmented.pos-bl .sncft-v5-pill { transform: translateX(100%); }
.sncft-v5-root.rtl .sncft-v5-segmented.pos-bl .sncft-v5-pill { transform: translateX(-100%); }

.sncft-v5-btn { 
    position: relative;
    z-index: 2;
    border: none; 
    background: transparent; 
    font-size: 14px; 
    font-weight: 700; 
    color: #ffffff; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 8px; 
    height: 100%;
    width: 50%;
    transition: color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
.sncft-v5-btn.active { color: #002b5c; font-weight: 800; }

.sncft-v5-badge { 
    font-size: 11px; 
    background: rgba(255, 255, 255, 0.25); 
    color: #ffffff; 
    padding: 2px 8px; 
    border-radius: 20px; 
    font-weight: 700; 
}
.sncft-v5-btn.active .sncft-v5-badge { background: #002b5c; color: #ffffff; }

/* --- KPIS --- */
.sncft-v5-kpis { display: flex; gap: 8px; width: 100%; justify-content: space-between; }
.sncft-v5-kpi-card { flex: 1; background: #f8fafc; border: 1px solid #e2e8f0; padding: 10px 6px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.sncft-v5-kpi-label { font-size: 11px; font-weight: 700; color: #64748b; text-transform: uppercase; white-space: nowrap; }
.sncft-v5-kpi-val { font-size: 18px; font-weight: 800; color: #0f172a; }

.sncft-v5-kpi-card.kpi-active { background: #ecfdf5; border-color: #a7f3d0; }
.sncft-v5-kpi-card.kpi-active .sncft-v5-kpi-val { color: #16a34a; }
.sncft-v5-kpi-card.kpi-delay { background: #fffbeb; border-color: #fde68a; }
.sncft-v5-kpi-card.kpi-delay .sncft-v5-kpi-val { color: #ea580c; }
.sncft-v5-kpi-card.kpi-cancelled { background: #fef2f2; border-color: #fecaca; }
.sncft-v5-kpi-card.kpi-cancelled .sncft-v5-kpi-val { color: #ef4444; }

/* --- LIST CONTAINER --- */
.sncft-v5-list { display: flex; flex-direction: column; gap: 12px; }

/* --- CARDS --- */
.sncft-v5-card { 
    background: #ffffff; border-radius: 20px; padding: 16px; border: 1px solid #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.01), 0 2px 4px -1px rgba(0,0,0,0.01); cursor: pointer; display: flex; flex-direction: column; gap: 14px;
    position: relative; overflow: hidden; transition: transform 0.15s, box-shadow 0.15s;
}
.sncft-v5-card:active { transform: scale(0.985); }
.sncft-v5-card:hover { box-shadow: 0 10px 20px -5px rgba(0, 51, 102, 0.08); }

.sncft-v5-card-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; }
.sncft-v5-card-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }

.sncft-v5-pill-num { background: #f1f5f9; padding: 4px 8px; border-radius: 8px; font-size: 11px; font-weight: 800; color: #475569; white-space: nowrap; }

.sncft-v5-card-title { 
    font-size: 16px; 
    font-weight: 800; 
    color: #002b5c; 
    margin: 0; 
    line-height: 1.35; 
    flex: 1;
    white-space: normal;
    word-break: break-word;
}

.sncft-v5-tag-status { font-size: 11px; padding: 4px 8px; border-radius: 8px; font-weight: 800; text-transform: uppercase; white-space: nowrap; }
.sncft-v5-ontime { color: #16a34a; background: #e8f5e9; border: 1px solid #c8e6c9; }
.sncft-v5-delay { color: #ef4444; background: #fef2f2; border: 1px solid #fecaca; }
.sncft-v5-notstarted { color: #475569; background: #f1f5f9; border: 1px solid #e2e8f0; }

.sncft-v5-route-line { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; color: #64748b; font-weight: 600; width: 100%; }
.sncft-v5-station { font-weight: 800; color: #0f172a; }
.sncft-v5-arrow { color: #94a3b8; font-size: 12px; }
.sncft-v5-root.rtl .sncft-v5-arrow { transform: scaleX(-1); }

.sncft-v5-meta-arrival { margin-inline-start: auto; font-size: 12px; color: #64748b; font-weight: 600; }
.sncft-v5-meta-arrival span { color: #002b5c; font-weight: 800; }

.sncft-v5-progress-wrap { background: #e2e8f0; height: 6px; border-radius: 3px; overflow: hidden; width: 100%; margin-top: 2px; }
.sncft-v5-progress-bar { height: 100%; background: linear-gradient(90deg, #002b5c, #0070f3); border-radius: 3px; }

.sncft-v5-card.cancelled { background: #fff5f5; border-color: #fecaca; }
.sncft-v5-card.cancelled .sncft-v5-card-title { text-decoration: line-through; color: #94a3b8; }
.sncft-v5-card.terminated { opacity: 0.75; }

.sncft-v5-empty { padding: 30px; text-align: center; color: #64748b; font-weight: 600; font-size: 14px; background: #ffffff; border-radius: 16px; border: 1px dashed #cbd5e1; width: 100%; }

/* --- MODAL --- */
.sncft-v5-modal { display: none; position: fixed; z-index: 200000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.6); align-items: flex-end; justify-content: center; backdrop-filter: blur(4px); }
.sncft-v5-modal-content { background: #ffffff; width: 100%; border-radius: 24px 24px 0 0; padding: 20px; max-height: 85vh; overflow-y: auto; box-shadow: 0 -10px 30px rgba(0,0,0,0.1); animation: sncft-v5-slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1); }

.sncft-v5-table { width: 100%; border-collapse: collapse; margin-top: 16px; }
.sncft-v5-table th { background: #f8fafc; color: #475569; font-weight: 700; font-size: 12px; padding: 12px 10px; text-align: inherit; border-bottom: 2px solid #e2e8f0; text-transform: uppercase; }
.sncft-v5-table td { padding: 14px 10px; border-bottom: 1px solid #f1f5f9; font-size: 14px; text-align: inherit; }

@keyframes sncft-v5-slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes sncft-v5-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes sncft-v5-pulse-anim { 0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.5); } 70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(22, 163, 74, 0); } 100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); } }

/* --- PC RESPONSIVE GRID GRID --- */
@media (min-width: 768px) {
    .sncft-v5-root { max-width: 1200px; padding: 24px; }
    
    .sncft-v5-list { 
        display: grid; 
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); 
        gap: 16px; 
    }
    
    .sncft-v5-cockpit { padding: 20px; gap: 18px; }
    
    .sncft-v5-filter-row {
        flex-direction: row;
        align-items: center;
        gap: 16px;
    }
    .sncft-v5-search-box { flex: 1; }
    .sncft-v5-segmented { width: 340px; }

    .sncft-v5-modal { align-items: center; padding: 16px; }
    .sncft-v5-modal-content { border-radius: 24px; max-width: 550px; }
}