:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.85);
    --border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #10b981;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Noto Sans KR', sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

input, textarea, [contenteditable="true"] {
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========================================================= */
/* 1. PC 최적화 반응형 관리자 화면 (http://t100.kr)          */
/* ========================================================= */

.admin-login-container {
    max-width: 440px;
    width: 90%;
    margin: 80px auto;
    padding: 2.5rem 2rem;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.admin-dashboard {
    display: none;
    padding: 2rem 2.5rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.admin-sec {
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 0 1.5rem 0;
}

.admin-sec > .card {
    width: 100% !important;
    box-sizing: border-box !important;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1.25rem;
    margin-bottom: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    text-align: center;
    transition: transform 0.2s, border-color 0.2s;
}

.stat-card:hover {
    border-color: #60a5fa;
    transform: translateY(-2px);
}

.stat-val {
    font-size: 2.2rem;
    font-weight: 700;
    color: #60a5fa;
    margin-top: 0.5rem;
}

.admin-nav {
    display: flex;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.85rem;
    margin-bottom: 1.75rem;
}

.admin-tab {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 600;
    padding: 0.65rem 1.25rem;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.admin-tab:hover, .admin-tab.active {
    color: white;
    background: var(--primary);
    border-color: var(--primary);
}

/* ========================================================= */
/* 2. Tree-List                                              */
/* ========================================================= */

.tree-scroll-wrapper {
    width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 650px;
    border-radius: 0.5rem;
    -webkit-overflow-scrolling: touch;
}

.tree-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    text-align: left;
}

.tree-node {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    margin-bottom: 0.4rem;
    overflow: hidden;
    text-align: left;
}

.tree-node-content {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 0.85rem 1.25rem;
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
}

.tree-node-content:hover {
    background: rgba(59, 130, 246, 0.1);
}

.tree-node-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 600;
    font-size: 1rem;
    text-align: left;
}

.tree-icon-toggle {
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.tree-icon-toggle.expanded {
    transform: rotate(90deg);
}

.tree-children {
    padding-left: 1rem;
    border-left: 2px dashed rgba(96, 165, 250, 0.3);
    margin: 0.25rem 0 0.5rem 0.5rem;
    text-align: left;
}

.tree-type-badge {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 0.25rem;
    font-weight: 700;
}
.badge-PLATFORM { background: #8b5cf6; color: white; }
.badge-ALLIANCE { background: #3b82f6; color: white; }
.badge-AGENCY { background: #10b981; color: white; }

/* ========================================================= */
/* 3. 모바일 전용 카카오 T 대리 방식 접수 레이아웃 UI      */
/* ========================================================= */

.mobile-app-wrapper {
    max-width: 480px;
    width: 100%;
    margin: 0 auto;
    min-height: 100vh;
    background: #0f172a;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 35px rgba(0, 0, 0, 0.9);
    position: relative;
}

/* 상단 메인 브랜드 헤더 */
.mobile-header {
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

/* 모바일 상단 탭 (좌측 전화걸기 플로팅 버튼 배치) */
.mobile-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(30, 41, 59, 0.95);
    border-bottom: 1px solid var(--border);
}

.floating-call-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #10b981;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0.45rem 0.9rem;
    border-radius: 9999px;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    transition: transform 0.2s, background 0.2s;
}

.floating-call-btn:hover {
    background: #059669;
    transform: scale(1.05);
}

.mobile-nav-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: rgba(30, 41, 59, 0.9);
    border-bottom: 1px solid var(--border);
}

.mobile-tab-btn {
    padding: 0.85rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    text-align: center;
    border-bottom: 2px solid transparent;
}

.mobile-tab-btn.active {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
    background: rgba(59, 130, 246, 0.1);
}

.mobile-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* 카카오 대리 스타일: 지도 상단 뷰 */
.mobile-map-box {
    width: 100%;
    height: 300px;
    min-height: 300px;
    position: relative;
    border-bottom: 1px solid var(--border);
}

/* 지도 하단: 카카오 T 대리 방식 출발지 -> 목적지 -> 접수 카드 */
.mobile-content-box {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Kakao Style Call Form Card */
.kakao-dispatch-card {
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(96, 165, 250, 0.3);
    border-radius: 1.25rem;
    padding: 1.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.kakao-input-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.6rem 0.9rem;
    margin-bottom: 0.75rem;
}

.kakao-input-row label {
    font-size: 0.85rem;
    font-weight: 700;
    width: 55px;
    flex-shrink: 0;
}

.kakao-input-row input {
    border: none;
    background: transparent;
    padding: 0.2rem 0;
    font-size: 0.95rem;
}

/* Common Components */
.card {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.35rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #93c5fd;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.input-group {
    margin-bottom: 0.9rem;
}

.input-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.input-row {
    display: flex;
    gap: 0.5rem;
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem 0.9rem;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: white;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
}

.btn {
    width: 100%;
    padding: 0.85rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn:hover {
    background: var(--primary-hover);
}

.btn-success {
    background: var(--accent);
}

.btn-success:hover {
    background: #059669;
}

.badge {
    background: #3b82f6;
    color: white;
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-weight: 600;
}

.status-pill {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
}
.status-PENDING { background: #eab308; color: black; }
.status-APPROVED { background: #10b981; color: white; }
.status-REQUESTED { background: #3b82f6; color: white; }

.history-item {
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 0;
}
.history-item:last-child {
    border-bottom: none;
}

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

@media (max-width: 640px) {
    .admin-dashboard {
        padding: 1rem;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .admin-nav {
        flex-direction: flex-start;
        overflow-x: auto;
    }
    .admin-tab {
        white-space: nowrap;
    }
}

/* SweetAlert2 최상위 레이어 고정 (브라우저 최고 32bit max z-index: 2147483647) */
.swal2-container,
.swal2-popup,
.swal2-backdrop-show,
.swal2-top,
.swal2-center,
.swal2-bottom {
    z-index: 2147483647 !important;
}
