/* design tokens */
:root {
    --color-bg: #f6f7fb;
    --color-surface: #ffffff;
    --color-border: #e3e6ec;
    --color-text: #1f2430;
    --color-text-muted: #6b7280;
    --color-primary: #2f6fed;
    --color-primary-hover: #2557c7;
    --color-primary-soft: #eaf1ff;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(16,24,40,.06);
    --shadow-md: 0 6px 20px rgba(16,24,40,.08);

    /* 표 헤더(th) 배경색 - 도착버스검색 결과 포함 전체 표 공통 */
    --th-popup: #cdaef8;
}

/* basic element */
body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
    font-size: 13px;
    background: var(--color-bg);
    color: var(--color-text);
    margin: 0;
}

/* 팝업(모달)이 열려있는 동안 배경 스크롤 잠금 */
html.no-scroll,
html.no-scroll body {
    overflow: hidden;
    height: 100%;
}

div {
    margin-top: 10px;
    margin-bottom: 10px;
}

#app {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 16px 48px;
    box-sizing: border-box;
}

h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 4px 0 0;
}

table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}
th, td {
    padding: 8px 14px;
}
th {
    background: var(--th-popup);
    color: #fff;
    text-align: left;
    font-weight: 600;
}
table tbody tr:hover {
    background-color: var(--color-primary-soft);
}
tr:first-child th:first-child {
    border-top-left-radius: var(--radius-sm);
}
tr:first-child th:last-child {
    border-top-right-radius: var(--radius-sm);
}
tr:last-child td:first-child {
    border-bottom-left-radius: var(--radius-sm);
}
tr:last-child td:last-child {
    border-bottom-right-radius: var(--radius-sm);
}
/* 도착정보 표는 rowspan 구조라 마지막 행에 우측 열이 없음 - 실제 우측 하단 모서리는 그 위 행의 rowspan 셀 */
.arrival-table tr:last-child td:last-child {
    border-bottom-right-radius: 0;
}
.arrival-table tr:nth-last-child(2) td:last-child {
    border-bottom-right-radius: var(--radius-sm);
}
td {
    border-right: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}
td:first-child {
    border-left: 1px solid var(--color-border);
}

/* 폭이 넓은 표를 위한 가로 스크롤 래퍼 */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

select {
    height: 30px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    padding: 0 8px;
}
select.h2w {
    height: 30px;
    width: 100px;
}
select.h2wx {
    height: 30px;
    width: 130px;
}
select.h2w2x {
    height: 30px;
    width: 180px;
}

input.w172 {
    width: 172px;
}
input[type="text"] {
    height: 30px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0 10px;
    box-sizing: border-box;
    font-size: 13px;
    color: var(--color-text);
}
input[type="text"]:focus, select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}

div.condbox {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 20px;
}
div.condbox label {
    color: var(--color-text-muted);
    font-size: 12px;
}

p.src {
    background: var(--color-primary-soft);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-size: 12px;
    padding: 8px 12px;
    margin: 0 0 20px;
}

/* 광고 배너 */
.ad-banner {
    position: relative;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    line-height: 0;
    margin-bottom: 20px;
}
.ad-banner img {
    display: block;
    width: 100%;
}
.ad-banner-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, .45);
    color: #fff;
    font-size: 15px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .3s;
}
.ad-banner-close:hover {
    background: rgba(0, 0, 0, .65);
}

/* 버튼 공통 */
button.arrival,
button.route,
button.map,
button.detail,
button.search,
button.search-map {
    border: none;
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background .15s ease;
}

/* secondary 액션 */
button.arrival,
button.route,
button.map,
button.detail,
button.search,
button.search-map {
    background: var(--color-primary-soft);
    color: var(--color-primary);
}
button.arrival:hover,
button.route:hover,
button.map:hover,
button.detail:hover,
button.search:hover,
button.search-map:hover {
    background: #d9e6ff;
}

/* primary 액션 (핵심 CTA) */
button.search-primary {
    background: var(--color-primary);
    color: #fff;
}
button.search-primary:hover {
    background: var(--color-primary-hover);
}
button.route {
    margin-top: 5px;
    width: auto;
}

div.map {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 3px;
}

/* 인덱스 링크 */
.main {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-top: 30px;
    margin-left: 30px;
    margin-right: 30px;
    padding-top: 30px;
}
.main > div {
    text-align: center;
    margin-bottom: 30px;
}
.main a {
    text-decoration: none;
    color: var(--color-text);
    font-weight: bold;
    font-size: 25px;
}
.main a > img {
    border-style: solid;
    border-radius: 30px;
    padding-left: 10px;
    padding-right: 10px;
    padding-bottom: 10px;
    width: 91%;
}

/* 로딩 이미지 */
#loading {
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    position: fixed;
    display: block;
    background: rgba(255, 255, 255, 0.85);
    z-index: 999;
    text-align: center;
}
#loading > img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    -webkit-transform: translate(-50%, -50%);
    -moz-transform: translate(-50%, -50%);
    -ms-transform: translate(-50%, -50%);
    -o-transform: translate(-50%, -50%);
    z-index: 1000;
}

/* 레이어 팝업 */
.dim-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, .7);
    z-index: 99999;
    display: none;
}
.layer-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    max-width: 90vw;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    z-index: 100000;
    display: none;
}
.popup-header {
    box-sizing: border-box;
    min-height: 50px;
    padding: 20px 15px;
    border-bottom: 1px solid var(--color-border);
    position: relative;
}
.popup-content {
    padding: 20px;
    margin-left: 10px;
    margin-right: 10px;
    border-radius: var(--radius-md);
    height: 255px;
}
.popup-footer {
    padding: 14px 15px 4px;
    text-align: right;
    border-top: 1px solid var(--color-border);
}
.close-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: var(--color-text-muted);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .3s;
}
.close-btn:hover {
    background: var(--color-text);
}
.confirm-btn {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
}
.confirm-btn:hover {
    background: var(--color-primary-hover);
}

/* 전체 화면 팝업 */
.fpopup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, .5);
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}
.fpopup-overlay.active {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
    box-sizing: border-box;
}
.fpopup-content {
    background: var(--color-surface);
    width: 100%;
    max-width: 640px;
    height: auto;
    max-height: 95%;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 10px;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    animation: slideIn 0.3s ease;
    box-sizing: border-box;
}
.fpopup-content::-webkit-scrollbar {
    width: 0px;
}
.fpopup-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}
.fpopup-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 5px;
}
.fpopup-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}
.fpopup-header {
    position: relative;
    padding: 14px 50px 14px 16px;
    border-bottom: 1px solid var(--color-border);
    margin: -10px -10px 16px;
}
.fpopup-header h3 {
    margin: 0;
    font-size: 16px;
}
.fpopup-footer {
    text-align: right;
    border-top: 1px solid var(--color-border);
    padding-top: 16px;
    margin-top: 16px;
}
.fclose-btn {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border: none;
    background: var(--color-text-muted);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .3s;
}
.fclose-btn:hover {
    background: var(--color-text);
}

/* 거리 최소/최대 간격 거리 */
.min-color {
    background-color: lightblue;
}
.max-color {
    background-color: lightpink;
}

/* 사이즈 */
.smt2 {
    margin-top: 2px;
}
.smt3 {
    margin-top: 3px;
}
.smt4 {
    margin-top: 4px;
}
.smt5 {
    margin-top: 5px;
}
.smt6 {
    margin-top: 6px;
}
.smt7 {
    margin-top: 7px;
}

.smb2 {
    margin-bottom: 2px;
}
.smb3 {
    margin-bottom: 3px;
}
.smb4 {
    margin-bottom: 4px;
}
.smb5 {
    margin-bottom: 5px;
}

.sml3 {
    margin-left: 3px;
}

.sw50 {
    width: 50px;
}
.sw100 {
    width: 100px;
}
.sw150 {
    width: 150px;
}
.sw200 {
    width: 200px;
}
.sw300 {
    width: 300px;
}
.sw400 {
    width: 400px;
}
.sw500 {
    width: 500px;
}

.sh50 {
    height: 50px;
}
.sh60 {
    height: 60px;
}
.sh70 {
    height: 70px;
}
.sh80 {
    height: 80px;
}
.sh90 {
    height: 90px;
}
.sh100 {
    height: 100px;
}
.sh120 {
    height: 120px;
}

.pw30 {
    width: 30%;
}
.pw40 {
    width: 40%;
}
.pw50 {
    width: 50%;
}
.pw60 {
    width: 60%;
}
.pw70 {
    width: 70%;
}
.pw80 {
    width: 80%;
}

/* 반응형 (모바일) */
@media (max-width: 640px) {
    #app {
        padding: 16px 12px 32px;
    }
    div.condbox {
        padding: 14px;
    }
    th, td {
        padding: 6px 8px;
        font-size: 12px;
    }
    button.arrival,
    button.route,
    button.map,
    button.detail,
    button.search,
    button.search-map {
        padding: 8px 12px;
    }

    /* 정류장 명/선택 요소 - 버튼 포함 풀 사이즈 */
    input.w172,
    select.h2w2x {
        width: 100%;
        box-sizing: border-box;
    }
    button.search,
    button.search-map {
        display: block;
        width: 100%;
        box-sizing: border-box;
        margin-top: 8px;
        text-align: center;
    }

    .fpopup-overlay.active {
        padding: 10px;
    }
}
