/* Custom Scrollbar (Gemini Slim Style) */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    /* 항상 보이게 기본값 설정, 라이트 테마는 은은한 파란색 */
    background: rgba(59, 130, 246, 0.4);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 130, 246, 0.7) !important;
}

/* Dark Theme specific thumb color (Light White) */
html[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3) !important;
}

/* Global scrollbar stability */
* {
    scrollbar-gutter: stable;
}

.customers-layout {
    height: calc(100vh - var(--header-height));
    display: grid;
    grid-template-columns: 310px 1fr 420px;
    gap: 10px;
    padding: 0 10px 10px 10px; /* 여백 축소 */
    align-items: stretch;
    transition: grid-template-columns 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.customers-layout.detail-collapsed {
    grid-template-columns: 310px 1fr 0px;
    gap: 10px 0px;
}

.customers-layout.detail-collapsed .detail-panel .panel-card {
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 접혔을 때도 패널 영역 자체는 클릭 가능해야 버튼이 작동함 */
.customers-layout.detail-collapsed .detail-panel {
    pointer-events: auto;
    overflow: visible !important;
}

/* Panel Common Styles */
.panel {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.detail-panel {
    position: relative;
    transform-origin: right;
    overflow: visible !important; /* Base.css의 overflow:hidden을 해제하여 버튼이 보이게 함 */
}

/* Sidebar Toggle Button */
.toggle-side-btn {
    position: absolute;
    left: -24px; /* 위치 고정 */
    top: 100px; /* 50%에서 100px로 고정 (슬라이딩 현상 방지) */
    width: 24px;
    height: 48px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    font-size: 10px;
    color: var(--muted);
    box-shadow: -4px 0 10px rgba(0,0,0,0.05);
    transition: all 0.2s;
}

.toggle-side-btn:hover {
    color: var(--text);
    background: var(--panel-2);
    width: 28px;
    left: -28px;
}

/* 접힌 상태일 때 버튼 위치 보정 (완전히 동일하게 맞춤) */
.detail-collapsed .toggle-side-btn {
    left: -24px;
    border: 1px solid var(--border);
    border-right: 1px solid var(--border); /* 접혔을 때는 오른쪽 경계도 필요할 수 있음 */
    border-radius: 8px 0 0 8px;
    box-shadow: -2px 0 15px rgba(0,0,0,0.1);
    background: var(--panel);
    color: var(--text);
}

.detail-collapsed .toggle-side-btn:hover {
    left: -28px;
    width: 28px;
}

.panel-head {
    height: 54px !important; /* 64px -> 54px */
    padding: 0 16px !important;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border) !important;
    box-sizing: border-box !important;
    background: var(--panel);
}

.panel-head h3 {
    margin: 0;
    font-size: 16px; /* 글씨 사이즈 통일 */
    font-weight: 700;
    line-height: 1;
}

.panel-body {
    padding: 10px 16px 16px 16px; /* 12/20/20 -> 10/16/16 */
    overflow-y: auto;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    padding: 0 20px;
    height: 48px; /* 탭 높이 고정 */
    align-items: stretch;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    padding: 0 16px;
    border: none;
    background: none;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    position: relative; /* 하단 라인을 위한 기준점 */
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    color: var(--primary); /* 선택 시 테마 포인트 컬러 사용 */
}

/* 선택된 탭 하단 빛나는 라인 효과 */
.tab-btn.active::after {
    content: "";
    position: absolute;
    bottom: -1px; /* 부모 border-bottom과 겹치게 하여 충돌 방지 */
    left: 10%;
    right: 10%;
    height: 3px;
    background: var(--primary); /* 테마 포인트 컬러 */
    border-radius: 10px 10px 0 0;
    box-shadow: 0 -1px 8px var(--primary); /* 테마 컬러에 맞는 은은한 글로우 */
    z-index: 2;
}

/* 다크모드에서는 더 강조된 발광 효과 */
html[data-theme="dark"] .tab-btn.active::after {
    background: #fff; /* 다크모드에서는 흰색으로 대비 강조 */
    box-shadow: 0 -1px 10px rgba(255, 255, 255, 0.8);
}

.tab-content.hidden {
    display: none;
}

.empty-state {
    padding: 40px 20px;
    text-align: center;
}

/* 1. Groups Panel Fixes */
.groups-panel .panel-head {
    padding: 0 20px;
}

.groups-panel .panel-head h3 {
    margin: 0;
    font-size: 15px; /* Slightly smaller for better balance */
    font-weight: 700;
    color: var(--text);
    text-transform: none;
    letter-spacing: -0.3px;
    line-height: 1.2;
}

/* Icon Button Small (v1.9.5) */
.icon-btn-sm {
    width: 28px;
    height: 28px;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px !important;
    border-radius: 6px;
    border: none !important;
    background: transparent;
    cursor: pointer;
    transition: background 0.2s;
}

.icon-btn-sm:hover {
    background: var(--panel-2) !important;
}

.groups-panel .panel-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.groups-panel .panel-body {
    padding: 8px 0;
    overflow-x: hidden; /* 가로 스크롤 제거 */
    overflow-y: auto; /* 세로 스크롤 */
    flex: 1;
    min-height: 0;
}

.group-tree {
    display: flex;
    flex-direction: column;
    width: 100%; /* 너비 100% 고정 */
}

.groups-panel .group-item {
    display: flex;
    align-items: center;
    padding: 0 16px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    transition: background 0.1s;
    white-space: nowrap;
    border: none;
    color: var(--text);
    position: relative;
    height: 32px;
    width: 100%; /* 너비 100% */
    box-sizing: border-box;
    overflow: hidden; /* 넘치는 내용 숨김 */
}

.groups-panel .group-item:hover {
    background: var(--panel-2);
}

/* 라이트 테마 하이라이트 */
.groups-panel .group-item.active {
    background: #eff6ff; /* 매우 연한 파랑 */
    color: #2563eb; /* 선명한 파랑 */
    font-weight: 600;
}

/* 다크 테마 하이라이트 */
html[data-theme="dark"] .groups-panel .group-item.active {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.group-count {
    margin-left: auto; /* 우측 끝으로 밀기 */
    font-size: 11px;
    opacity: 0.6;
    font-weight: 600;
    flex-shrink: 0; /* 숫자는 줄어들지 않음 */
    text-align: right;
    padding-left: 8px;
    padding-right: 0px; /* 가장 우측으로 붙임 */
    min-width: 28px;
}

.group-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1; /* 가용한 공간 모두 차지 */
    min-width: 0; /* ellipsis 작동을 위한 필수 설정 */
}

.sub-group-container {
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
}

/* 가이드라인(바) 강화: 라이트 모드에서 파란색 계열 적용 */
.sub-group-container::before {
    content: "";
    position: absolute;
    left: 27px;
    top: 0;
    bottom: 0;
    width: 1.5px;
    background: #3b82f6; /* 명확한 파란색 */
    opacity: 0.4; /* 너무 진하지 않게 조절 */
    z-index: 1;
    pointer-events: none;
}

/* 다크모드 가이드라인 */
html[data-theme="dark"] .sub-group-container::before {
    background: #60a5fa;
    opacity: 0.3;
}

.caret {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 6px;
    flex-shrink: 0;
    cursor: pointer;
    z-index: 5;
    transition: all 0.2s ease;
    color: var(--muted);
}

/* CSS Border 기반 삼각형 - 모든 브라우저에서 보장됨 */
.caret::before {
    content: "";
    display: block;
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 7px solid currentColor; /* 부모 색상 상속 */
    transition: transform 0.2s ease;
}

/* 부모 .group-item에 .open 클래스가 있을 때 90도 회전하여 아래(Down)를 가리킴 */
.group-item.open .caret::before {
    transform: rotate(90deg);
}

.caret:hover {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    color: var(--primary);
}

/* 기존 SVG 스타일 제거 */
.caret svg {
    display: none !important;
}

/* 활성화된 행이나 호버 시 체브론 강조 */
.group-item:hover .caret,
.group-item.active .caret {
    color: inherit;
}

.folder-icon {
    margin-right: 6px;
    font-size: 14px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.group-name {
    flex-shrink: 0;
}

.folder-icon {
    margin-right: 6px;
    font-size: 14px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.group-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

/* 2. List & Detail Panel Alignment */
.list-panel .panel-head.row,
.detail-panel .panel-head.row {
    justify-content: space-between;
}

/* detail-panel 내부 panel-body: 탭+폼 영역이 카드 높이 내에서 스크롤 */
.detail-panel .panel-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.detail-panel .panel-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* list-panel panel-card: flex-column으로 테이블 영역이 남은 공간 차지 */
.list-panel .panel-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Sticky Header & High Density */
.grid thead th {
    position: sticky;
    top: 0;
    background: var(--panel);
    z-index: 10;
    padding: 10px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border);
    color: var(--muted);
    font-weight: 700;
}

.grid tbody tr {
    height: 44px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}

.grid tbody td {
    padding: 0 10px;
}

.grid tbody tr:hover {
    background: var(--panel-2);
}

.grid tbody tr.active {
    background: var(--panel-2);
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

/* Company Cell Styling */
.cell-company {
    color: var(--primary);
    font-weight: 600;
}

.cell-company:hover {
    text-decoration: underline;
}

/* Progress Text Badge (v1.9.8f) */
.progress-text-badge {
    display: inline-flex; /* align with .badge */
    align-items: center;
    justify-content: center;
    padding: 4px 12px; /* Increased padding for larger font */
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px; /* Changed from 11px */
    font-weight: 700;
    color: var(--muted);
    min-width: 50px; /* Match badge sizing */
    line-height: 1; /* align with .badge */
    box-sizing: border-box;
}

.progress-text-badge.full {
    background: #f0fdf4;
    color: #16a34a;
    border-color: #bbf7d0;
}

html[data-theme="dark"] .progress-text-badge.full {
    background: rgba(22, 163, 74, 0.2);
    color: #4ade80;
    border-color: rgba(22, 163, 74, 0.3);
}

/* Note Icon */
.note-trigger {
    font-size: 16px;
    opacity: 0.7;
    cursor: pointer;
}

.note-trigger:hover {
    opacity: 1;
}

/* Bulk Action Bar */
.bulk-bar {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--panel);
    padding: 10px 24px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    z-index: 100;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bulk-bar.hidden {
    bottom: -60px;
    opacity: 0;
}

.bulk-bar button {
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 12px;
    margin-left: 8px;
    color: var(--panel);
    border-color: var(--panel);
    opacity: 0.9;
}

.bulk-bar button:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .bulk-bar button:hover {
    background: rgba(0, 0, 0, 0.05);
}

.bulk-separator {
    width: 1px;
    height: 20px;
    background: var(--panel);
    margin: 0 15px;
    opacity: 0.3;
}

#selectedCount {
    font-size: 13px;
    font-weight: 700;
}

.group-tree .group-item {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.edit-group-btn {
    margin-left: auto;
    opacity: 0;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    cursor: pointer;
    transition: opacity 0.2s;
}

.group-tree .group-item:hover .edit-group-btn {
    opacity: 1;
}

.edit-group-btn:hover {
    color: var(--text);
    background: var(--border);
}

/* 2. List & Detail Panel Alignment */
.list-panel .panel-head.row,
.detail-panel .panel-head.row {
    justify-content: space-between;
}

#btnSave {
    border: 1px solid #22c55e;
    background: transparent;
    color: var(--text);
    font-weight: 700;
}

#btnSave:hover {
    background: rgba(34, 197, 94, 0.05);
}

#q {
    width: 240px;
}

/* 3. Table Readability */
.grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.grid thead th {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-weight: 800;
    font-size: 14.5px;
}

#confirmModal {
    z-index: 3000;
}

.grid tbody td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
}

.grid tbody tr:hover {
    background: var(--panel-2);
}

.grid tbody tr.active {
    background: var(--panel-2);
    outline: 2px solid var(--border);
    outline-offset: -2px;
}

.mgmt-row-selected {
    outline: 2px solid #ef4444 !important;
    outline-offset: -2px;
    background: rgba(239, 68, 68, 0.05) !important;
}

/* Common Layout Components */
.row {
    display: flex;
    align-items: center;
}

/* Normalize Input/Select/Button Height and Vertical Alignment */
.input, .assignee-picker {
    margin-top: 6px !important; /* Match base.css global margin */
}

.input {
    display: block;
    width: 100%;
    height: 40px !important;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    outline: none;
    line-height: 38px; /* Adjustment for border */
    box-sizing: border-box;
}

/* Date input theme fix */
input[type="date"] {
    color-scheme: light;
}
html[data-theme="dark"] input[type="date"] {
    color-scheme: dark;
}

select.input {
    padding: 0 12px;
    cursor: pointer;
}

.memo {
    width: 100%;
    min-height: 120px;
    padding: 12px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    outline: none;
    resize: vertical;
    line-height: 1.45;
}

/* Note Timeline */
.note-list {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 15px; /* 간격 소폭 확대 */
    padding-right: 4px;
    /* max-height 제거: 모달 높이 전체 활용 (v2.2.3) */
    /* overflow-y 제거: 이중 스크롤 방지 */
}

.note-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    background: var(--panel);
}

.note-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 4px;
}

.note-author {
    font-weight: 700;
}

.note-content {
    white-space: pre-wrap;
    word-wrap: break-word; /* Ensure wrapping */
    line-height: 1.45;
    font-size: 13px;
}

/* Checklist - Side Panel Version */
.checklist {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel-2);
}

.check-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0; /* slightly more padding for touch targets */
    font-size: 13px;
    cursor: pointer;
}

.check-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.check-item.done .title {
    text-decoration: line-through;
    color: var(--muted);
}

.check-item .title {
    white-space: normal; /* Allow wrapping in side panel */
    word-break: break-all;
}

/* Group Tree Drag & Drop Handle */
.group-item .drag-handle {
    cursor: grab;
    color: var(--muted);
    padding: 0 4px;
    font-size: 12px;
    opacity: 0.5;
}

.group-item:hover .drag-handle {
    opacity: 1;
}

.sortable-ghost {
    opacity: 0.4;
    background: var(--primary) !important;
}

/* Details UI */
.label {
    margin-top: 8px !important; /* 10px -> 8px */
    margin-bottom: 2px !important; /* 3px -> 2px */
    font-weight: 600;
    font-size: 12px;
    color: var(--text);
}

.tab-content > .label:first-child,
.tab-content > .row:first-child .label {
    margin-top: 0 !important;
}

.tab-content .input,
.tab-content select,
.tab-content .input-like {
    margin-bottom: 0 !important;
}

.note-compose {
    margin-bottom: 20px;
}

.assignee-picker {
    position: relative;
    width: 100%;
}

.assignee-list.expand-up {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 5px;
}

.assignee-picker .input-like {
    width: 100%;
    height: 40px !important;
    margin: 0 !important; /* Reset margin since parent has it */
    padding: 0 12px;
    text-align: left;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
    border-radius: 10px;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    font-weight: 400; /* Match input font weight */
}

.assignee-list {
    position: absolute;
    top: 100%; /* Expansion downwards */
    bottom: auto;
    left: 0;
    right: 0;
    background: var(--panel);
    border: 1px solid var(--border);
    z-index: 100;
    border-radius: 12px;
    margin-top: 5px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    max-height: 240px;
    overflow-y: auto;
}

.assignee-list.hidden { display: none; }

.assignee-item {
    width: 100%;
    padding: 12px 14px;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.assignee-item:last-child {
    border-bottom: none;
}

.assignee-item:hover {
    background: var(--panel-2);
}

/* Modal Core Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

/* Log Table Ref인ements */
.log-table {
    text-align: left;
}

.log-table th, .log-table td {
    text-align: left !important;
    white-space: nowrap;
}

.log-table th:nth-child(2), .log-table td:nth-child(2) {
    width: 100px !important; /* Reduced width for '사용자' */
}

.log-table td:last-child {
    white-space: normal;
    word-break: break-all;
}

.log-date-wrap {
    display: flex;
    flex-direction: column;
    font-size: 11px;
    line-height: 1.3;
}

.log-date-wrap .date {
    font-weight: 600;
}

.log-date-wrap .time {
    color: var(--text);
    opacity: 0.8;
}

.mgmt-row-selected {
    background: rgba(239, 68, 68, 0.08) !important;
    position: relative;
}

.mgmt-row-selected td:first-child {
    border-left: 3px solid #ef4444;
}

.modal.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-card {
    position: relative;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

/* 4. Dark Theme Native Calendar Fix */
html[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    filter: invert(0.8);
}
/* Note Preview in Table Row */
.note-preview-inline {
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    word-break: break-all;
}

/* Badge Styles (v1.9.4) */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 12px; /* Match progress badge */
    border-radius: 6px;
    font-size: 13px; /* Changed from 11px */
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    min-width: 50px; /* Match progress badge */
    box-sizing: border-box;
}

.badge-muted {
    background: var(--surface);
    color: var(--muted);
    border: 1px solid var(--border);
}

.badge-primary {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

.badge-success {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

html[data-theme="dark"] .badge-primary {
    background: rgba(37, 99, 235, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(37, 99, 235, 0.3);
}

html[data-theme="dark"] .badge-success {
    background: rgba(22, 163, 74, 0.2);
    color: #4ade80;
    border: 1px solid rgba(22, 163, 74, 0.3);
}

/* Badge Info (Teal - Between Blue and Green) */
.badge-info {
    background: #f0fdfa;
    color: #0d9488;
    border: 1px solid #99f6e4;
}

html[data-theme="dark"] .badge-info {
    background: rgba(13, 148, 136, 0.2);
    color: #2dd4bf;
    border: 1px solid rgba(13, 148, 136, 0.3);
}

/* Badge Indigo (For Contracting) */
.badge-indigo {
    background: #eef2ff;
    color: #4f46e5;
    border: 1px solid #c7d2fe;
}

/* Badge Warning (Orange - For Hold status) (v2.2.8) */
.badge-warning {
    background: #fff7ed;
    color: #ea580c; /* Changed from #c2410c to a brighter orange */
    border: 1px solid #ffedd5;
}

html[data-theme="dark"] .badge-warning {
    background: rgba(234, 88, 12, 0.2);
    color: #fdba74; /* Brighter orange for dark mode */
    border: 1px solid rgba(234, 88, 12, 0.3);
}

html[data-theme="dark"] .badge-indigo {
    background: rgba(79, 70, 229, 0.2);
    color: #818cf8;
    border: 1px solid rgba(79, 70, 229, 0.3);
}




/* Pagination Styles */
.pagination-container {
    display: flex;
    justify-content: center;
    padding: 12px 0;
    background: var(--panel);
    border-top: 1px solid var(--border);
    z-index: 20;
    flex-shrink: 0; /* 푸터가 줄어들지 않도록 고정 */
}

.pagination-nav {
    display: flex;
    gap: 5px;
}

.page-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    background: var(--panel-2);
    border-color: var(--primary);
    color: var(--primary);
}

.page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.filter-btn {
    padding: 6px 14px;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: var(--surface);
    color: var(--text);
}

.filter-btn.active {
    background: var(--primary);
    color: var(--primary-contrast);
}

/* Toast Notification (v1.9.4) */
#toastContainer {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: #1e293b;
    color: white;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: toast-in 0.3s ease-out forwards, toast-out 0.3s ease-in 3.7s forwards;
    pointer-events: auto;
    opacity: 1 !important; /* Force visibility to override base.css */
    transform: translateY(0); /* Override base.css */
    transition: none !important; /* Disable transition from base.css */
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-20px); }
}

/* Header Filter Styles (v2.1.0) */
.header-filter-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 4px; /* vertical padding removed to align with checkbox */
    align-items: center; /* Checkbox centering */
}

.header-filter-select, .header-filter-input {
    width: 100%;
    height: 24px;
    font-size: 11px;
    padding: 0 4px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--panel);
    color: var(--text);
    outline: none;
    box-sizing: border-box;
}

.header-filter-select:focus, .header-filter-input:focus {
    border-color: var(--primary);
}

.header-filter-input {
    text-align: center; /* Center text in date filter */
    padding-right: 20px; /* Space for X button */
}

.header-filter-clear {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--muted);
    font-size: 10px;
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.header-filter-clear:hover {
    color: var(--danger);
}

.grid thead th {
    vertical-align: top; /* 상단 정렬로 변경 */
    padding: 12px 4px !important;
    height: 65px; /* 필터 공간 확보를 위해 약간 높임 */
    box-sizing: border-box;
}

.grid thead th:first-child .header-filter-wrap {
    padding: 0;
    justify-content: flex-start; /* 상단부터 배치 */
    margin-top: 2px; /* 체크박스 높이를 글자 중간에 맞춤 */
}

.log-details-cell {
    font-size: 13px;
    color: var(--text);
    max-width: 350px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.9;
}

.log-row {
    cursor: pointer;
    transition: background-color 0.2s;
}

.log-row:hover {
    background-color: var(--panel-2);
}

.log-row.active-log-row {
    background-color: var(--color-bg-active, rgba(59, 130, 246, 0.1)) !important;
    color: var(--color-text-active, #1d4ed8);
}

.log-row.active-log-row td {
    color: inherit;
}

/* Center-align specific columns (v1.9.7o) */
.grid td:nth-child(3), /* 전화번호 */
.grid td:nth-child(4), /* 진행 */
.grid td:nth-child(5), /* 상태 */
.grid td:nth-child(6), /* 담당자 */
.grid td:nth-child(7)  /* 등록일 */ {
    text-align: center;
}

.grid tbody td:first-child {
    text-align: center;
}

/* Date filter specific */
.header-filter-date {
    cursor: pointer;
    text-align: center;
    background: var(--panel-2) !important;
}

/* Flatpickr Custom Presets (v2.3.0) */
.flatpickr-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
    justify-content: center;
}

.flatpickr-preset-btn {
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.flatpickr-preset-btn:hover, .flatpickr-preset-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* 4x3 Month Grid */
.flatpickr-month-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 12px;
    background: var(--panel);
}

.month-grid-btn {
    padding: 10px 0;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
}

.month-grid-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

html[data-theme="dark"] .flatpickr-calendar {
    background: #1e1e1e;
    border-color: #333;
}

/* 추천인 입력 영역 애니메이션 (v1.9.9b) */
.expand-wrapper {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.expand-wrapper.expanded {
  grid-template-rows: 1fr;
}

.expand-content {
  min-height: 0;
  opacity: 0;
  transition: opacity 0.3s ease 0.1s;
}

.expand-wrapper.expanded .expand-content {
  opacity: 1;
}

/* v1.9.9b 액티브 강조 가이드 - 테두리 글로우 효과 통일 */
.input:focus,
.input-like:focus,
.input-like:active {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 4px var(--focus) !important;
  outline: none;
  background-color: var(--panel); /* 배경색 유지 */
}

/* Date input focus style fix */
input[type="date"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--focus);
}

.input-like {
  transition: border-color 0.2s, box-shadow 0.2s;
}

/* 🚀 Customer Timeline Styles (v2.1.0) */
.timeline-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 10px 5px;
    position: relative;
}

/* 수직 타임라인 선 */
.timeline-list::before {
    content: "";
    position: absolute;
    left: 20px;
    top: 20px;
    bottom: 20px;
    width: 2px;
    background: var(--border);
    z-index: 1;
}
.timeline-item {
    display: flex;
    gap: 12px;
    padding-bottom: 20px;
    position: relative;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}

.timeline-item:hover {
    background: var(--bg);
}

.timeline-item.active {
    background: rgba(16, 185, 129, 0.08); /* 초록색 틴트 */
    border: 2px solid #10b981 !important; /* 선명한 초록색 테두리 */
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
    padding: 8px;
    margin-bottom: 12px;
}

.timeline-item > * {
    position: relative;
    z-index: 2;
}

.timeline-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--panel);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.timeline-content {
    flex: 1;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
    transition: transform 0.2s;
}

.timeline-item:hover .timeline-content {
    transform: translateX(2px);
    border-color: var(--primary);
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.timeline-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.timeline-author {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.timeline-time {
    font-size: 11px;
    color: var(--muted);
}

.timeline-body {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-all;
}

.timeline-item .badge {
    padding: 2px 8px;
    font-size: 10px;
}

/* License & D-Day Badges (v2.2.0) */
.badge-dday-red {
    background: #ff4d4f;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    margin-left: 4px;
    animation: blink 2s infinite;
}

@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

.license-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

.license-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 15px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.license-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.license-card.inactive {
    opacity: 0.6;
    background: var(--bg);
}

.lic-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

.lic-type {
    font-weight: 700;
    font-size: 14px;
    color: var(--primary);
}

.lic-status {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg);
    border: 1px solid var(--border);
}

.lic-body {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
}

.lic-next strong {
    color: #ff4d4f;
}

.badge-disp {
    font-size: 11px;
    color: #fa8c16;
    background: #fff7e6;
    border: 1px solid #ffd591;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 4px;
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.btn-text:hover {
    color: var(--primary-dark);
}

/* 보류 사유 관리 및 상태 배지 (v2.2.8) */
.status-badge.status-보류중 {
    background: #fff7ed !important;
    color: #ea580c !important; /* Brighter orange */
    border: 1px solid #ffedd5 !important;
}

html[data-theme="dark"] .status-badge.status-보류중 {
    background: rgba(234, 88, 12, 0.2) !important;
    color: #fdba74 !important; /* Brighter orange */
    border: 1px solid rgba(234, 88, 12, 0.3) !important;
}

.checklist.hold-checklist {
    background: var(--bg);
    margin-top: 10px;
    border-radius: 8px;
    padding: 8px;
}

.check-item.hold-item {
    border-left: 4px solid #f97316 !important;
    margin-bottom: 6px;
    background: var(--panel);
}

.check-item.hold-item.done {
    background: #fff7ed !important;
}

html[data-theme="dark"] .check-item.hold-item.done {
    background: #431407 !important;
}

/* 🚀 Group Tree Engine Styles (v2.2.12 - Multi-modal Support) */
.group-tree-container {
    user-select: none;
}

.group-tree-container .group-item {
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    position: relative;
    overflow: hidden;
}

.group-tree-container .group-item * {
    pointer-events: none; /* 아이콘이나 텍스트가 클릭을 방해하지 않도록 설정 */
}

.group-tree-container .caret, 
.group-tree-container .caret-wrapper {
    pointer-events: auto !important; /* 화살표 버튼은 클릭 가능해야 함 */
}

.group-tree-container .group-item:hover {
    background: var(--panel-2);
}

.group-tree-container .group-item.active {
    background: #eff6ff !important;
    color: #2563eb !important;
    font-weight: 700;
    box-shadow: inset 0 0 0 1px #bfdbfe;
}

html[data-theme="dark"] .group-tree-container .group-item.active,
html[data-theme="dark"] .group-tree-container .group-tree-item.active {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.4);
}

.group-tree-container .caret {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.group-tree-container .caret:hover {
    background: rgba(0,0,0,0.05);
}

.group-tree-container .group-tree-item {
    border: 1px solid transparent;
    transition: all 0.2s;
}

.group-tree-container .sub-group-container {
    padding-left: 0;
    transition: all 0.3s ease;
}

#groupTreeSearch:focus, #bulkGroupTreeSearch:focus {
    box-shadow: 0 0 0 4px var(--focus);
    border-color: var(--primary);
}

/* detail-panel 내부 패널 카드 및 패널 바디 높이 연쇄 고리 강화 */
.detail-panel {
    position: relative;
    transform-origin: right;
    height: 100%;
    min-height: 0;
}

.detail-panel .panel-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
}

.detail-panel .panel-body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: calc(100% - 90px); /* 탭과 상단 버튼 영역 제외 */
    overflow-y: auto !important;
    overflow-x: hidden;
    padding: 16px;
}

.detail-panel .tab-content {
    padding-bottom: 30px; /* 하단 폼 입력 박스 여유 공간 */
}

/* 우측 사이드바(detail-panel) 커스텀 스크롤바 선명도 강화 */
.detail-panel .panel-body::-webkit-scrollbar {
    width: 8px !important;
}

.detail-panel .panel-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.detail-panel .panel-body::-webkit-scrollbar-thumb {
    background: #3b82f6 !important;
    border-radius: 4px;
}

.detail-panel .panel-body::-webkit-scrollbar-thumb:hover {
    background: #2563eb !important;
}

html[data-theme="dark"] .detail-panel .panel-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

html[data-theme="dark"] .detail-panel .panel-body::-webkit-scrollbar-thumb {
    background: #60a5fa !important;
}

html[data-theme="dark"] .detail-panel .panel-body::-webkit-scrollbar-thumb:hover {
    background: #93c5fd !important;
}

/* 테이블 래퍼: 헤더 고정 + 본문 스크롤 (실제 thead 높이 82px 아래부터 스크롤바 시작 및 정보탭 디자인 통일) */
.list-table-wrapper {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

.list-table-wrapper::-webkit-scrollbar {
    width: 8px !important;
}

.list-table-wrapper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    margin-top: 82px; /* thead 테이블 헤더(82px) 바로 아래부터 수직 스크롤바 시작 */
}

.list-table-wrapper::-webkit-scrollbar-thumb {
    background: #3b82f6 !important;
    border-radius: 4px;
}

.list-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #2563eb !important;
}

html[data-theme="dark"] .list-table-wrapper::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

html[data-theme="dark"] .list-table-wrapper::-webkit-scrollbar-thumb {
    background: #60a5fa !important;
}

html[data-theme="dark"] .list-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #93c5fd !important;
}

.list-table-wrapper .grid {
    width: 100%;
}

.list-table-wrapper .grid thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--panel);
}

/* 처리 수수료 타임테이블 스타일 */
.fee-timeline-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
    padding-right: 4px;
}

.fee-timeline-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    transition: all 0.2s ease;
}

.fee-timeline-item:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.04);
}

.fee-amount-text {
    font-weight: 700;
    font-size: 14px;
    color: var(--primary);
}

.fee-info-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fee-date-text {
    font-size: 11px;
    color: var(--text);
    opacity: 0.6;
}

.fee-delete-btn {
    padding: 2px 6px;
    font-size: 11px;
    border: none;
    background: transparent;
    color: var(--text);
    opacity: 0.5;
    cursor: pointer;
    border-radius: 4px;
}

.fee-delete-btn:hover {
    color: #ef4444;
    opacity: 1;
    background: rgba(239, 68, 68, 0.1);
}
