* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'KoPub Dotum', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', sans-serif; font-size: 16px; background: #f0f2f5; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* Header */
#header { background: #1a1a2e; color: #fff; height: 60px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
#header h1 { font-size: 18px; font-weight: 600; }
#user-area { position: relative; }
#user-btn { background: #2d2d44; border: 1px solid #444; color: #fff; padding: 4px 12px; border-radius: 4px; cursor: pointer; font-size: 14px; display: flex; align-items: center; gap: 8px; }
#user-btn:hover { background: #3a3a55; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; }
#user-dropdown { position: absolute; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid #ddd; border-radius: 4px; min-width: 248px; box-shadow: 0 4px 16px rgba(0,0,0,.18); z-index: 900; display: none; overflow: hidden; }
#user-dropdown.open { display: block; }
.dd-user-info { padding: 12px 16px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid #f0f0f0; }
.dd-user-info .u-name { font-size: 16px; font-weight: 600; color: #111; }
.dd-user-info .u-role { font-size: 12px; color: #888; margin-top: 1px; }
.dd-action { padding: 8px 16px; display: flex; align-items: center; gap: 8px; cursor: pointer; color: #333; font-size: 16px; }
.dd-action:hover { background: #f5f5f5; }
.dd-action.danger { color: #dc2626; }
.dd-action.danger:hover { background: #fef2f2; }

/* Main */
#main { display: flex; flex: 1; overflow: hidden; min-height: 0; }

/* Sidebar */
#sidebar { width: 340px; background: #fff; border-right: 1px solid #e0e0e0; display: flex; flex-direction: column; flex-shrink: 0; }

.task-queue-info { font-size: 12px; color: #888; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 56%; }

/* Sidebar controls */
#task-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }

/* Task cards */
.task-card { border: 1px solid #e8e8e8; border-radius: 4px; padding: 8px 12px; margin-bottom: 4px; cursor: pointer; background: #fff; transition: border-color .15s; position: relative; }
.task-card:hover { border-color: #22c55e; }
.task-card.active { border-color: #22c55e; background: #f0fdf4; }
.task-card-top { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; padding-right: 24px; }
.type-badge { font-size: 10px; font-weight: 800; padding: 1px 4px; border-radius: 3px; flex-shrink: 0; }
.type-badge.cepa { background: #f0fdf4; color: #166534; }
.type-badge.depa { background: #dcfce7; color: #15803d; }
.task-title { font-size: 14px; font-weight: 600; color: #222; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-card-bot { display: flex; align-items: center; justify-content: space-between; }
.task-species-type { font-size: 12px; color: #777; font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52%; }
.task-badges { display: flex; align-items: center; gap: 4px; }
.pub-badge { font-size: 10px; padding: 1px 4px; border-radius: 3px; background: #e0f2fe; color: #0369a1; font-weight: 600; }
.st { font-size: 12px; font-weight: 700; padding: 2px 4px; border-radius: 3px; }
.st.queued      { background: #f4f4f5; color: #71717a; }
.st.in_progress { background: #fef9c3; color: #854d0e; animation: blink 1.6s ease-in-out infinite; }
.st.success     { background: #dcfce7; color: #166534; }
.st.failed      { background: #fee2e2; color: #991b1b; }
.st.interrupted { background: #ffedd5; color: #9a3412; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.5} }
.task-reason { margin-top: 4px; font-size: 12px; color: #999; background: #fafafa; border-left: 2px solid #e0e0e0; padding: 2px 4px; border-radius: 0 3px 3px 0; }
.card-del-btn { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 3px; background: none; border: none; cursor: pointer; color: #bbb; font-size: 16px; display: flex; align-items: center; justify-content: center; }
.card-del-btn:hover { background: #fee2e2; color: #dc2626; }

/* Detail panel */
#detail-wrap { width: 0; overflow: hidden; flex-shrink: 0; transition: width 0.18s ease; }
#detail-wrap.open { width: 448px; border-right: 1px solid #d4d4d4; }
#detail-panel { width: 448px; height: 100%; display: flex; flex-direction: column; background: #fff; }
#detail-head { padding: 12px 16px; border-bottom: 1px solid #e8e8e8; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
#detail-head-title { font-size: 16px; font-weight: 600; color: #222; }
#detail-close { background: none; border: none; font-size: 24px; color: #888; cursor: pointer; line-height: 1; padding: 2px 4px; }
#detail-close:hover { color: #333; }
#detail-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.field-group { display: flex; flex-direction: column; gap: 3px; }
.field-label { font-size: 12px; font-weight: 700; color: #888; text-transform: uppercase; letter-spacing: 0.4px; }
.field-group input, .field-group select, .field-group textarea { border: 1px solid #e0e0e0; border-radius: 3px; padding: 4px 8px; font-size: 14px; width: 100%; font-family: inherit; outline: none; color: #222; background: #fff; }
.field-group input:focus, .field-group select:focus, .field-group textarea:focus { border-color: #22c55e; }
.field-group input[readonly], .field-group textarea[readonly] { background: #f8f8f8; color: #555; }
.field-group textarea { resize: vertical; min-height: 64px; }
.type-tabs { display: flex; border: 1px solid #e0e0e0; border-radius: 4px; overflow: hidden; }
.ttab { flex: 1; padding: 4px 0; text-align: center; font-size: 14px; font-weight: 600; cursor: pointer; border: none; background: #fff; color: #aaa; }
.ttab.active-cepa { background: #f0fdf4; color: #15803d; }
.ttab.active-depa { background: #dcfce7; color: #166534; }
.reason-box { background: #fff8f2; border: 1px solid #fde8d0; border-radius: 3px; padding: 4px 8px; font-size: 14px; color: #b45309; }
.bio-grid { display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 0; }
.bio-badge { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 12px; border: 1px solid #e0e0e0; background: #f5f5f5; color: #bbb; cursor: pointer; user-select: none; transition: all .12s; }
.bio-badge.selected { background: #f0fdf4; border-color: #86efac; color: #166534; }
.bio-badge.readonly { cursor: default; }
.bio-badge.unused-ex { background: #fff3cd; border-color: #f59e0b; color: #92400e; cursor: default; }
.var-legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 4px; padding: 4px 8px; background: #f8f9fa; border-radius: 4px; }
.var-legend-item { display: flex; align-items: center; gap: 4px; font-size: 12px; color: #555; }
.var-legend-dot { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.var-section-label { font-size: 12px; font-weight: 700; color: #888; text-transform: uppercase; letter-spacing: 0.4px; margin: 4px 0 3px; }
.param-section { margin-top: 8px; }
.param-section:first-child { margin-top: 0; }
.param-section-title { font-size: 12px; font-weight: 700; color: #333; text-transform: uppercase; letter-spacing: 0.4px; padding: 4px 0 4px; border-bottom: 1px solid #e8e8e8; margin-bottom: 4px; }
.param-list { display: flex; flex-direction: column; gap: 3px; }
.param-row { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 3px; border: 1px solid #f0f0f0; background: #fff; transition: background .12s; }
.param-row:not(.readonly):hover { background: #fafafa; }
.param-row.disabled { background: #f8f8f8; border-color: #f0f0f0; }
.param-row input[type=checkbox] { flex-shrink: 0; width: 16px; height: 16px; cursor: pointer; accent-color: #22c55e; margin: 0; }
.param-row input[type=checkbox]:disabled { cursor: default; }
.param-row-meta { flex: 1; min-width: 0; }
.param-row-label { font-size: 12px; font-weight: 700; color: #333; line-height: 1.3; }
.param-row-desc { font-size: 10px; color: #aaa; line-height: 1.3; margin-top: 1px; }
.param-row.disabled .param-row-label { color: #bbb; text-decoration: line-through; }
.param-row.disabled .param-row-desc { color: #ddd; }
.param-row input[type=number] { width: 92px; flex-shrink: 0; padding: 4px 4px; font-size: 14px; border: 1px solid #e0e0e0; border-radius: 3px; font-family: inherit; outline: none; text-align: right; color: #222; background: #fff; }
.param-row input[type=number]:focus { border-color: #22c55e; }
.param-row input[type=number]:disabled { background: #f0f0f0; color: #ccc; border-color: #ebebeb; }
.param-row.readonly input[type=number] { background: #f8f8f8; color: #555; }
.toggle-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: #ccc; border-radius: 24px; cursor: pointer; transition: background .2s; }
.toggle-slider:before { content: ''; position: absolute; width: 20px; height: 20px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: transform .2s; }
.toggle-switch input:checked + .toggle-slider { background: #22c55e; }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(16px); }
.toggle-label { font-size: 14px; color: #444; }
.toggle-hint { font-size: 12px; color: #aaa; margin-top: 2px; }
#detail-foot { padding: 12px 16px; border-top: 1px solid #e8e8e8; display: flex; gap: 8px; flex-shrink: 0; }
.foot-btn { padding: 8px 12px; border-radius: 4px; font-size: 14px; font-weight: 600; cursor: pointer; border: none; }
.foot-btn.primary { background: #22c55e; color: #fff; flex: 1; }
.foot-btn.primary:hover { background: #16a34a; }
.foot-btn.secondary { background: #fff; border: 1px solid #ddd; color: #555; }
.foot-btn.secondary:hover { background: #f5f5f5; }
.foot-btn.danger { background: #fff; border: 1px solid #dc2626; color: #dc2626; }
.foot-btn.danger:hover { background: #fee2e2; }
.foot-btn.warn { background: #fff; border: 1px solid #d97706; color: #d97706; }
.foot-btn.warn:hover { background: #fffbeb; }
.foot-btn.pub-btn { min-width: 100px; }
.foot-btn.pub-btn.is-public { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
.foot-btn.pub-btn.is-public:hover { background: #dcfce7; }
.foot-btn.pub-btn.is-private { background: #f8f8f8; border: 1px solid #d4d4d4; color: #888; }
.foot-btn.pub-btn.is-private:hover { background: #f0f0f0; }
.foot-btn.pub-btn.requested { background: #f8f8f8; border: 1px solid #d4d4d4; color: #aaa; cursor: not-allowed; }
.foot-btn.pub-btn.requested:hover { background: #f8f8f8; }
#stop-modal-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1000; align-items: center; justify-content: center; }
#stop-modal-bg.open { display: flex; }
#stop-modal { background: #fff; border-radius: 4px; padding: 24px 28px; width: 424px; box-shadow: 0 8px 32px rgba(0,0,0,.2); }
#stop-modal h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
#stop-modal p { font-size: 14px; color: #666; margin-bottom: 8px; }
#stop-reason-input { width: 100%; border: 1px solid #e0e0e0; border-radius: 3px; padding: 8px 8px; font-size: 14px; font-family: inherit; outline: none; resize: vertical; min-height: 88px; }
#stop-reason-input:focus { border-color: #22c55e; }
.modal-btns { display: flex; gap: 8px; margin-top: 12px; }
.modal-confirm { flex: 1; padding: 8px; background: #dc2626; color: #fff; border: none; border-radius: 4px; font-size: 16px; font-weight: 600; cursor: pointer; }
.modal-confirm:hover { background: #b91c1c; }
.modal-cancel { padding: 8px 16px; background: #fff; border: 1px solid #ddd; border-radius: 4px; font-size: 16px; cursor: pointer; color: #555; }

/* Center */
#center { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
#map-toolbar { background: #fff; border-bottom: 1px solid #e0e0e0; padding: 4px 16px; display: flex; align-items: center; flex-shrink: 0; min-height: 0; }
#active-label { font-size: 12px; color: #888; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; text-align: right; }
.legend-thr-row { display: flex; align-items: center; gap: 4px; margin: 4px 0 4px; }
.legend-thr-row label { font-size: 12px; color: #888; white-space: nowrap; }
.legend-thr-row input[type=range] { flex: 1; accent-color: #22c55e; cursor: pointer; }
.legend-thr-row span { font-size: 12px; font-weight: 700; color: #111; min-width: 32px; text-align: right; }
#map { flex: 1; min-height: 0; }
.leaflet-control-north { background: rgba(255,255,255,0.92); border: 1px solid #ccc; border-radius: 4px; padding: 4px 8px; box-shadow: 0 1px 5px rgba(0,0,0,.25); cursor: default; line-height: 0; }
#top5-ctrl { min-width: 284px; }
.top5-title { font-size: 12px; font-weight: 700; color: #555; letter-spacing: 0.2px; margin-bottom: 4px; padding-bottom: 4px; border-bottom: 1px solid #eee; }
.top5-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 4px; }
.top5-list li { font-size: 12px; color: #333; display: flex; align-items: center; gap: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top5-list li::before { content: '•'; color: #22c55e; font-size: 14px; line-height: 1; flex-shrink: 0; }
.top5-empty { font-size: 12px; color: #aaa; text-align: center; padding: 3px 0; }
#map-legend { display: flex; flex-direction: column; gap: 4px; pointer-events: auto; }
.map-ctrl-box { background: rgba(255,255,255,.95); border: 1px solid #ddd; border-radius: 4px; padding: 8px 12px; font-size: 12px; color: #555; line-height: 1.4; min-width: 172px; box-shadow: 0 1px 5px rgba(0,0,0,.15); }
.legend-bar { width: 100%; height: 12px; background: rgba(210,45,45,0.82); border-radius: 2px; margin: 3px 0; transition: background .2s; }
.legend-labels { display: flex; justify-content: space-between; font-size: 10px; color: #888; }
.legend-radios { display: flex; gap: 12px; margin-bottom: 4px; padding-bottom: 4px; border-bottom: 1px solid #eee; }
.legend-radios label { display: flex; align-items: center; gap: 3px; cursor: pointer; font-size: 12px; color: #555; user-select: none; }
.legend-radios input[type=radio] { cursor: pointer; accent-color: #22c55e; margin: 0; }

/* Right panel */
#right-panel { width: 424px; background: #fff; border-left: 1px solid #e0e0e0; display: flex; flex-direction: column; flex-shrink: 0; }
.ssp-label { font-size: 12px; font-weight: 700; color: #888; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px; }

/* Body: selector */
#rp-body { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
#rp-sel-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.rp-sel-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #fff; border: 1px solid #e8e8e8; border-radius: 4px; transition: border-color .12s, background .12s; }
.rp-sel-item:hover { border-color: #22c55e; background: #f9fefb; }
.rp-sel-item.map-active { border-color: #22c55e; background: #f0fdf4; border-left-width: 3px; }
.rp-sel-item input[type=checkbox] { flex-shrink: 0; cursor: pointer; accent-color: #22c55e; margin: 0; }
.rp-sel-info { min-width: 0; flex: 1; }
.rp-sel-type { font-size: 10px; font-weight: 800; display: block; line-height: 1.2; margin-bottom: 1px; }
.rp-sel-type.cepa { color: #15803d; }
.rp-sel-type.depa { color: #166534; }
.rp-sel-name { font-size: 14px; font-weight: 700; color: #111; display: block; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-sel-owner { font-size: 12px; color: #888; display: block; margin-top: 2px; }
.rp-sel-empty { padding: 12px 8px; font-size: 12px; color: #ccc; text-align: center; line-height: 1.5; }
.rp-map-btn { flex-shrink: 0; height: 24px; border: 1px solid #d4d4d4; background: #fff; cursor: pointer; color: #555; font-size: 12px; font-weight: 600; padding: 0 8px; display: flex; align-items: center; gap: 3px; border-radius: 3px; white-space: nowrap; }
.rp-map-btn:hover { background: #f0fdf4; border-color: #22c55e; color: #15803d; }
.rp-map-btn.active { color: #15803d; background: #dcfce7; border-color: #86efac; }
.rp-map-btn.disabled-map { color: #ccc; border-color: #ebebeb; cursor: not-allowed; }
.rp-map-btn.disabled-map:hover { background: #fff; color: #ccc; border-color: #ebebeb; }
.metrics-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 2px; }
.metrics-table th { background: #f8f9fa; padding: 4px 8px; text-align: left; font-size: 12px; font-weight: 700; color: #888; border-bottom: 1px solid #e8e8e8; }
.metrics-table th:not(:first-child) { text-align: right; }
.metrics-table td { padding: 4px 8px; border-bottom: 1px solid #f0f0f0; color: #555; font-size: 12px; }
.metrics-table td.mval { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.mval.good { color: #16a34a; }
.mval.mid  { color: #d97706; }
.mval.poor { color: #dc2626; }

/* 지도 생성 버튼 */
#rp-gen { margin-bottom: 0; }
#gen-btn { width: 100%; padding: 8px; font-size: 14px; font-weight: 700; background: #22c55e; color: #fff; border: none; border-radius: 4px; cursor: pointer; }
#gen-btn:hover:not(:disabled) { background: #16a34a; }
#gen-btn:disabled { background: #c8c8d0; color: #888; cursor: not-allowed; }
#rp-footer { padding: 8px 12px; border-top: 1px solid #e8e8e8; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; }
.map-dl-row { display: flex; gap: 4px; }
.map-dl-btn { flex: 1; padding: 4px 4px; font-size: 12px; font-weight: 600; background: #fff; border: 1px solid #bbb; border-radius: 4px; cursor: pointer; color: #555; display: flex; align-items: center; justify-content: center; gap: 4px; }
.map-dl-btn:hover { background: #f0fdf4; border-color: #22c55e; color: #15803d; }
.upload-label { display: flex; align-items: center; gap: 4px; padding: 4px 8px; border: 1px dashed #d0d0d0; border-radius: 3px; cursor: pointer; font-size: 12px; color: #888; background: #fafafa; transition: border-color .15s; }
.upload-label:hover { border-color: #22c55e; color: #15803d; background: #f0fdf4; }
.upload-label input[type=file] { display: none; }
.upload-filename { font-size: 12px; color: #555; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 2px; }

#occ-info-bar { font-size: 12px; color: #b84d09; font-weight: 600; display: none; align-items: center; gap: 4px; flex-shrink: 0; margin-right: 12px; background: #fff8f2; border: 1px solid #fcd5ae; border-radius: 4px; padding: 3px 8px 3px 8px; }
.occ-dot { width: 8px; height: 8px; border-radius: 50%; background: #f39c12; flex-shrink: 0; border: 1.5px solid #c05a0c; }
