:root {
    --bg-color: #f0f2f5;
    --text-primary: #1a1d23;
    --text-secondary: #6b7280;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --card-bg: rgba(255, 255, 255, 0.75);
    --card-border: rgba(0, 0, 0, 0.08);
    --beopjeong-color: #7c3aed;
    --haengjeong-color: #059669;
}

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

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Helvetica Neue', 'Segoe UI', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
}

.background-blobs {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.35;
    animation: float 10s ease-in-out infinite alternate;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--beopjeong-color), transparent 70%);
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--haengjeong-color), transparent 70%);
    animation-delay: -5s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(50px, 50px) scale(1.1);
    }
}

.container {
    width: 100%;
    max-width: 800px;
    padding: 2rem;
    z-index: 1;
    margin: auto;
}

header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.8s ease-out;
}

h1 {
    font-size: 3.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.dot {
    color: var(--accent);
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.search-section {
    margin-bottom: 3rem;
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

.input-group {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 100px;
    padding: 0.5rem 0.5rem 0.5rem 1.5rem;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.input-group:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2), 0 20px 40px rgba(0, 0, 0, 0.2);
}

.search-icon {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 1.1rem;
    padding: 0.8rem 1rem;
    font-family: inherit;
}

input::placeholder {
    color: var(--text-secondary);
    opacity: 0.8;
}

button {
    background: var(--accent);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 100px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    white-space: nowrap;
}

button:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

.result-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.result-section.hidden {
    display: none;
}

.result-section:not(.hidden) {
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.result-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 2.5rem 2rem;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.result-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.result-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
}

.result-card.beopjeong::before {
    background: var(--beopjeong-color);
}

.result-card.haengjeong::before {
    background: var(--haengjeong-color);
}

.card-header {
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.icon-bg {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.beopjeong .icon-bg {
    background: rgba(139, 92, 246, 0.2);
    color: var(--beopjeong-color);
}

.haengjeong .icon-bg {
    background: rgba(16, 185, 129, 0.2);
    color: var(--haengjeong-color);
}

.icon-bg svg {
    width: 24px;
    height: 24px;
}

.card-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.badge {
    margin-left: auto;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.3rem 0.8rem;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.beopjeong .badge {
    background: rgba(139, 92, 246, 0.1);
    color: var(--beopjeong-color);
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.haengjeong .badge {
    background: rgba(16, 185, 129, 0.1);
    color: var(--haengjeong-color);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.dong-name {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.2;
    min-height: 3rem;
}

.beopjeong .dong-name {
    background: linear-gradient(to right, #1e1b4b, var(--beopjeong-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.haengjeong .dong-name {
    background: linear-gradient(to right, #064e3b, var(--haengjeong-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

.map-container {
    margin-top: 2rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 2.5rem 2rem;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.2s both;
}

.map-icon-bg {
    background: rgba(59, 130, 246, 0.2);
    color: var(--accent);
}

.map-element {
    width: 100%;
    height: 400px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.loading {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto 1rem;
}

.error-message {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #dc2626;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-top: 2rem;
    animation: fadeIn 0.3s ease;
}

.error-message svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.hidden {
    display: none !important;
}

/* Integrated Bulk Upload Icon Button */
.btn-upload-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.btn-upload-icon:hover {
    color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
    transform: translateY(-2px);
}

.btn-upload-icon svg {
    width: 22px;
    height: 22px;
}

/* Tooltip Styles */
.upload-tooltip-wrapper {
    position: relative;
    display: inline-block;
}

.guideline-tooltip {
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    width: 280px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    pointer-events: none;
}

.guideline-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -8px;
    border-width: 8px;
    border-style: solid;
    border-color: var(--card-bg) transparent transparent transparent;
}

.upload-tooltip-wrapper:hover .guideline-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.tooltip-header {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.guideline-tooltip p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.4;
}

.guideline-tooltip p strong {
    color: #ef4444;
}

/* Mini Excel Grid */
.mini-excel {
    display: grid;
    grid-template-columns: 30px 1fr 1fr;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    overflow: hidden;
    font-size: 0.75rem;
    text-align: center;
}

.e-header,
.e-row {
    background: #334155;
    color: #94a3b8;
    padding: 4px;
    font-weight: 600;
    border-right: 1px solid #475569;
    border-bottom: 1px solid #475569;
}

.e-header:first-child {
    background: transparent;
    border-bottom: 1px solid #475569;
}

.e-cell {
    padding: 4px 6px;
    text-align: left;
    border-right: 1px solid #334155;
    border-bottom: 1px solid #334155;
    color: #f8fafc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.e-cell.empty {
    background: rgba(0, 0, 0, 0.1);
}

/* Bulk Progress Styles */
.bulk-progress-container {
    margin-top: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.5rem;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: fadeIn 0.3s ease;
    position: relative;
}

.close-progress-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border-radius: 50%;
}

.close-progress-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.close-progress-btn svg {
    width: 20px;
    height: 20px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-weight: 600;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 100px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 100px;
    transition: width 0.3s ease;
}

.progress-warning {
    font-size: 0.85rem;
    color: #f59e0b;
    text-align: center;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .result-section {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 2.5rem;
    }

    .container {
        padding: 1.5rem;
    }
}

/* ==========================================
   DARK MODE
   ========================================== */
[data-theme="dark"] {
    --bg-color: #000000;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --card-bg: rgba(18, 18, 18, 0.85);
    --card-border: rgba(255, 255, 255, 0.1);
    --beopjeong-color: #8b5cf6;
    --haengjeong-color: #10b981;
}

[data-theme="dark"] .blob {
    opacity: 0.5;
}

/* 다크모드에서 동 이름 그라디언트 복원 (흰색 시작) */
html[data-theme="dark"] .beopjeong .dong-name {
    background: linear-gradient(to right, #ffffff, var(--beopjeong-color)) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

html[data-theme="dark"] .haengjeong .dong-name {
    background: linear-gradient(to right, #ffffff, var(--haengjeong-color)) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

[data-theme="dark"] .mini-excel {
    background: #111;
    border-color: #2a2a2a;
}

[data-theme="dark"] .e-header,
[data-theme="dark"] .e-row {
    background: #1a1a1a;
    color: #64748b;
    border-color: #2a2a2a;
}

[data-theme="dark"] .e-cell {
    color: #f8fafc;
    border-color: #222;
}

[data-theme="dark"] .e-cell.empty {
    background: rgba(255, 255, 255, 0.02);
}

/* ==========================================
   THEME TOGGLE BUTTON
   ========================================== */
.theme-toggle {
    position: fixed;
    top: 1.2rem;
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 100px;
    padding: 0.45rem 1rem 0.45rem 0.6rem;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transition: all 0.25s ease;
    user-select: none;
}

.theme-toggle:hover {
    color: var(--text-primary);
    border-color: var(--accent);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.2);
    transform: translateY(-1px);
}

.theme-toggle:active {
    transform: translateY(0);
}

/* Toggle track */
.toggle-track {
    width: 36px;
    height: 20px;
    border-radius: 100px;
    background: #d1d5db;
    position: relative;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

[data-theme="dark"] .toggle-track {
    background: var(--accent);
}

/* Toggle thumb */
.toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] .toggle-thumb {
    transform: translateX(16px);
}

/* Icon inside button */
.toggle-icon {
    font-size: 0.9rem;
    line-height: 1;
    transition: transform 0.4s ease;
}

[data-theme="dark"] .toggle-icon {
    transform: rotate(180deg);
}