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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    display: block;
    width: 100%;
}

.api-header {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    padding: 20px 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.header-container {
    max-width: none;
    width: 100%;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.header-nav-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
}

.header-nav-links .home-link {
    font-size: 1em;
    padding: 8px 16px;
}

/* 좌·우 네비 대칭으로 가운데 제목 정렬 */
.header-container--balanced > .header-nav-links {
    flex: 1;
}

.header-container--balanced > .header-nav-links:first-of-type {
    justify-content: flex-start;
}

.header-container--balanced > .header-nav-links:last-of-type {
    justify-content: flex-end;
}

.header-container--balanced > .api-title {
    flex: 0 0 auto;
    text-align: center;
}

.home-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    text-decoration: none;
    font-size: 1.2em;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.home-link:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    color: white;
    text-decoration: none;
}

.api-title {
    color: white;
    font-size: 2em;
    font-weight: bold;
    margin: 0;
}

.api-container {
    max-width: none;
    width: 100%;
    margin: 0 auto;
    padding: 120px 20px 40px;
}

.api-intro {
    background: white;
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.api-intro h2 {
    color: #333;
    font-size: 1.8em;
    margin-bottom: 15px;
}

.api-intro p {
    color: #666;
    font-size: 1.1em;
    line-height: 1.6;
    margin-bottom: 20px;
}

.api-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

/* 부서 메뉴: 바둑판 그리드 → 펼치면 API 목록 → API별 상세 카드 */
.api-list.api-list-accordion {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    width: 100%;
    max-width: none;
    margin-left: auto;
    margin-right: auto;
    align-items: start;
}

.api-dept-block {
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    border: 1px solid #e9ecef;
    overflow: hidden;
    min-width: 0;
}

.api-dept-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 700;
    color: #2d3748;
    list-style: none;
}

.api-dept-summary::-webkit-details-marker {
    display: none;
}

.api-dept-summary::after {
    content: '';
    flex-shrink: 0;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 7px solid #667eea;
    transition: transform 0.2s ease;
}

.api-dept-block[open] > .api-dept-summary::after {
    transform: rotate(180deg);
}

.api-dept-summary__main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.api-dept-summary__icon {
    color: #667eea;
    width: 1.25rem;
    text-align: center;
}

.api-dept-summary__text {
    flex: 1;
    min-width: 0;
}

.api-dept-summary__meta {
    font-size: 0.85rem;
    font-weight: 600;
    color: #718096;
    white-space: nowrap;
}

.api-dept-inner {
    padding: 0 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.api-card-fold {
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #f7fafc;
    overflow: hidden;
}

.api-card-fold__title {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    cursor: pointer;
    font-weight: 600;
    color: #2d3748;
    list-style: none;
    font-size: 0.98rem;
}

.api-card-fold__title::-webkit-details-marker {
    display: none;
}

.api-card-fold__title::after {
    content: '';
    flex-shrink: 0;
    width: 0;
    height: 0;
    margin-left: auto;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #764ba2;
    transition: transform 0.2s ease;
}

.api-card-fold[open] > .api-card-fold__title::after {
    transform: rotate(180deg);
}

.api-card-fold__title-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    font-size: 0.95em;
}

.api-card-fold__title-text {
    flex: 1;
    min-width: 0;
    text-align: left;
}

.api-card-fold__body {
    padding: 0 8px 12px;
}

.api-card--nested {
    margin: 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.api-card--nested:hover {
    transform: none;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.api-dept-block--muted .api-dept-summary {
    color: #4a5568;
}

.api-card {
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 1px solid #e9ecef;
}

.api-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

.api-card-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.api-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.8em;
}

.api-info h3 {
    color: #333;
    font-size: 1.3em;
    margin-bottom: 5px;
}

.api-info .department {
    color: #666;
    font-size: 0.9em;
    font-weight: 500;
}

.api-description {
    color: #555;
    font-size: 0.95em;
    line-height: 1.5;
    margin-bottom: 20px;
}

.api-details {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: 600;
    color: #495057;
    font-size: 0.9em;
}

.detail-value {
    color: #666;
    font-size: 0.9em;
    text-align: right;
    max-width: 200px;
    word-break: break-all;
}

.api-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.action-button {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.action-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.3);
    color: white;
    text-decoration: none;
}

.action-button.secondary {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
}

.action-button.secondary:hover {
    box-shadow: 0 5px 15px rgba(108, 117, 125, 0.3);
}

.add-api-section {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    text-align: center;
    border: 2px dashed #dee2e6;
}

.add-api-section h3 {
    color: #666;
    font-size: 1.4em;
    margin-bottom: 15px;
}

.add-api-section p {
    color: #999;
    font-size: 1em;
    margin-bottom: 20px;
}

.add-api-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.add-api-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.add-api-modal-lead {
    font-size: 0.92em;
    color: #495057;
    line-height: 1.5;
    margin-bottom: 14px;
}

.add-api-paste-textarea {
    width: 100%;
    font-family: ui-monospace, monospace;
    font-size: 0.82em;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    resize: vertical;
}

.add-api-fields-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
}

@media (max-width: 640px) {
    .add-api-fields-grid {
        grid-template-columns: 1fr;
    }
}

.add-api-fields-grid .form-group input,
.add-api-fields-grid .form-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 0.95em;
}

.field-hint {
    font-size: 0.82em;
    color: #6c757d;
    margin: 4px 0 8px;
    line-height: 1.45;
}

.data-go-kr-extra-params-textarea {
    width: 100%;
    font-family: ui-monospace, monospace;
    font-size: 0.85em;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    resize: vertical;
}

.data-go-kr-extra-params-group {
    grid-column: 1 / -1;
}

.api-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 600;
    text-transform: uppercase;
}

.status-approved {
    background: #d4edda;
    color: #155724;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
}

.status-rejected {
    background: #f8d7da;
    color: #721c24;
}

.api-test-panel {
    background: white;
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.test-panel-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.test-panel-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5em;
}

.test-panel-title {
    color: #333;
    font-size: 1.4em;
    font-weight: 600;
}

.test-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-weight: 600;
    color: #495057;
    font-size: 0.9em;
}

.form-group input, .form-group select {
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.9em;
    transition: border-color 0.3s ease;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.test-button {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 20px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    grid-column: 1 / -1;
    justify-self: center;
}

.test-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 193, 7, 0.3);
}

.test-button:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.api-result {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-top: 20px;
    border: 1px solid #e9ecef;
    display: none;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
}

.result-title {
    font-weight: 600;
    color: #333;
    font-size: 1.1em;
}

.result-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 600;
}

.status-success {
    background: #d4edda;
    color: #155724;
}

.status-error {
    background: #f8d7da;
    color: #721c24;
}

.result-content {
    background: white;
    border-radius: 8px;
    padding: 15px;
    border: 1px solid #e9ecef;
    max-height: 400px;
    overflow-y: auto;
}

.result-content.result-content--with-map {
    max-height: min(85vh, 920px);
}

.data-go-kr-result-map-wrap {
    margin-bottom: 16px;
}

.data-go-kr-result-map-wrap .result-map-caption {
    display: block;
    font-size: 0.9em;
    font-weight: 600;
    color: #495057;
    margin-bottom: 8px;
}

.data-go-kr-result-map-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.data-go-kr-result-map-toolbar label {
    font-size: 0.85em;
    font-weight: 600;
    color: #495057;
    margin: 0;
    cursor: pointer;
}

.data-go-kr-result-map-toolbar input[type="range"] {
    flex: 1;
    min-width: 140px;
    max-width: 360px;
    cursor: pointer;
}

.data-go-kr-map-height-label {
    font-family: ui-monospace, monospace;
    font-size: 0.85em;
    color: #6c757d;
    min-width: 52px;
}

.data-go-kr-result-map {
    width: 100%;
    height: 320px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    background: #e9ecef;
}

/* 카카오 InfoWindow: 마커 호버 시 응답 필드 요약 */
.data-go-kr-map-iw {
    max-width: 300px;
    max-height: 260px;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.45;
    color: #212529;
    box-sizing: border-box;
}

.data-go-kr-map-iw__title {
    font-weight: 700;
    margin-bottom: 6px;
    font-size: 13px;
    color: #1a1a1a;
}

.data-go-kr-map-iw__body {
    margin-top: 2px;
}

.data-go-kr-map-iw__block + .data-go-kr-map-iw__sep {
    margin-top: 6px;
}

.data-go-kr-map-iw__row {
    display: grid;
    grid-template-columns: minmax(76px, 36%) 1fr;
    gap: 4px 8px;
    margin-top: 4px;
    align-items: start;
}

.data-go-kr-map-iw__k {
    color: #6c757d;
    font-size: 11px;
    word-break: break-all;
}

.data-go-kr-map-iw__v {
    word-break: break-word;
    font-size: 11px;
}

.data-go-kr-map-iw__coords {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid #dee2e6;
    font-size: 11px;
    color: #495057;
}

.data-go-kr-map-iw__sep {
    height: 1px;
    margin: 8px 0 4px;
    background: #dee2e6;
}

.result-url {
    background: #e9ecef;
    padding: 10px;
    border-radius: 5px;
    font-family: monospace;
    font-size: 0.85em;
    word-break: break-all;
    margin-bottom: 15px;
}

.result-data {
    font-family: monospace;
    font-size: 0.85em;
    white-space: pre-wrap;
    color: #333;
}

.result-view-tabs {
    margin-top: 4px;
}

.result-view-tablist {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 0;
}

.result-view-tab {
    appearance: none;
    border: 1px solid transparent;
    border-bottom: none;
    background: #e9ecef;
    color: #495057;
    padding: 8px 16px;
    font-size: 0.88em;
    font-weight: 600;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    margin-bottom: -1px;
    transition: background 0.2s ease, color 0.2s ease;
}

.result-view-tab:hover {
    background: #dee2e6;
    color: #212529;
}

.result-view-tab.is-active {
    background: #fff;
    color: #667eea;
    border-color: #dee2e6;
    border-bottom-color: #fff;
    position: relative;
    z-index: 1;
}

.result-view-panel {
    min-height: 80px;
}

.result-view-panel[hidden] {
    display: none !important;
}

#resultPanelRaw .result-data {
    max-height: 360px;
    overflow: auto;
    margin: 0;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 0 8px 8px 8px;
    border: 1px solid #dee2e6;
}

.result-content.result-content--with-map #resultPanelRaw .result-data {
    max-height: min(50vh, 420px);
}

.result-table-empty {
    margin: 0;
    padding: 16px;
    font-size: 0.9em;
    color: #6c757d;
    background: #f8f9fa;
    border: 1px dashed #ced4da;
    border-radius: 0 8px 8px 8px;
}

.result-table-scroll {
    max-height: min(55vh, 480px);
    overflow: auto;
    border: 1px solid #dee2e6;
    border-radius: 0 8px 8px 8px;
    background: #fff;
}

.result-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82em;
}

.result-data-table th,
.result-data-table td {
    border: 1px solid #e9ecef;
    padding: 8px 10px;
    text-align: left;
    vertical-align: top;
    word-break: break-word;
}

.result-data-table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}

.result-data-table tbody tr:nth-child(even) {
    background: #f8f9fa;
}

.result-data-table tbody tr:hover {
    background: #eef2ff;
}

.result-data-table__cell-media {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    min-width: 0;
}

.result-data-table__img-link {
    display: inline-block;
    line-height: 0;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #dee2e6;
    background: #f1f3f5;
    max-width: 100%;
}

.result-data-table__thumb {
    display: block;
    width: auto;
    height: auto;
    max-width: 140px;
    max-height: 100px;
    object-fit: cover;
    vertical-align: middle;
}

.result-data-table__url-fallback {
    display: none;
    font-size: 0.75em;
    word-break: break-all;
    color: #495057;
    line-height: 1.35;
}

.result-data-table__url-fallback.is-visible {
    display: block;
}

.loading {
    display: none;
    text-align: center;
    padding: 20px;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .api-container {
        padding: 100px 15px 30px;
    }

    .api-list:not(.api-list-accordion) {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .api-list.api-list-accordion {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .api-dept-summary {
        flex-wrap: wrap;
        padding: 14px 16px;
    }

    .api-dept-summary__meta {
        width: 100%;
        padding-left: 2rem;
    }

    .api-card {
        padding: 20px;
    }

    .api-actions {
        flex-direction: column;
    }

    .action-button {
        text-align: center;
        justify-content: center;
    }

    .test-form {
        grid-template-columns: 1fr;
    }

    .data-go-kr-result-map-toolbar input[type="range"] {
        max-width: none;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .api-header {
        padding: 15px 0;
    }

    .api-title {
        font-size: 1.5em;
    }

    .api-card-header {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .detail-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .detail-value {
        text-align: left;
        max-width: 100%;
    }
}
