:root {
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    
    --text-main: #2d3748;
    --text-muted: #718096;
    
    --accent-projects: #4299e1;
    --accent-personnel: #48bb78;
    --accent-others: #9f7aea;
    --accent-favorites: #d69e2e;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background: var(--bg-gradient);
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.glass-header {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.2rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--glass-shadow);
    margin-bottom: 2rem;
    position: relative;
    z-index: 1000; /* Ensure header is above dashboard content */
    overflow: visible !important;
}

.col-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
    border-bottom: 2px solid rgba(255,255,255,0.4);
    margin-bottom: 0.8rem;
}

.matched-header {
    border-top: 3px solid #ed8936;
    border-radius: 12px 12px 0 0;
}
.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: #2b6cb0;
}

.logo h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.glass-btn {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--glass-border);
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.glass-btn:hover:not(:disabled) {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.glass-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.glass-btn.primary {
    background: #4299e1;
    color: white;
    border: none;
}

.glass-btn.primary:hover:not(:disabled) {
    background: #3182ce;
}

.dashboard {
    min-height: 70vh;
}

.actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative; /* Contain the absolute panel */
    overflow: visible;
}

.search-filter-container {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 99px;
    padding: 2px 5px 2px 15px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
    width: 320px !important; /* Fixed width */
    overflow: visible;
    z-index: 1001;
}


.search-filter-container:focus-within {
    background: rgba(0, 0, 0, 0.08);
    border-color: var(--accent-projects);
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

.global-search-input {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 0.9rem;
    flex: 1;
    outline: none;
    width: 100%;
}

/* Header Dropdown Menu */
.header-menu-container {
    position: relative;
}

.header-dropdown {
    position: absolute;
    top: calc(100% + 15px);
    right: 0;
    width: 220px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.15);
    border: 1px solid rgba(0,0,0,0.08);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 2005;
}

.header-dropdown.hidden {
    display: none;
}

.dropdown-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.92rem;
    color: #4a5568;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.dropdown-item:hover {
    background: #f7fafc;
    color: #2d3748;
}

.dropdown-item i {
    width: 18px;
    text-align: center;
}




.global-search-input::placeholder {
    color: var(--text-muted);
}

.filter-plus-btn {
    background: white;
    color: var(--accent-main);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    margin-left: 8px;
    transition: transform 0.2s, background 0.2s;
}

.filter-plus-btn:hover {
    transform: scale(1.1);
    background: #edf2f7;
}

.filter-settings-panel {
    position: absolute;
    top: calc(100% + 15px);
    right: 0;
    background: #ffffff !important;
    color: #2d3748 !important;
    border-radius: 14px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.25);
    padding: 24px;
    width: 300px;
    z-index: 99999;
    border: 1px solid #cbd5e0;
    transition: all 0.2s ease;
    display: flex !important;
    flex-direction: column;
    gap: 1.2rem;
    min-height: 260px;
    overflow: visible;
}

.filter-settings-panel.hidden {
    display: none !important;
}

.filter-settings-panel::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 15px;
    width: 16px;
    height: 16px;
    background: #ffffff;
    transform: rotate(45deg);
    border-top: 1px solid #e2e8f0;
    border-left: 1px solid #e2e8f0;
    z-index: -1;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.filter-group.row {
    flex-direction: row;
    align-items: center;
}

.filter-group label {
    font-size: 0.85rem;
    font-weight: 700;
    color: #4a5568;
}

.filter-group input[type="checkbox"] + span {
    font-weight: 500;
}

.filter-group select,
.filter-group input[type="number"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    font-size: 0.9rem;
    background-color: #f8fafc;
    color: #2d3748;
    outline: none;
    transition: border-color 0.2s;
}

.filter-group select:focus,
.filter-group input[type="number"]:focus {
    border-color: #4299e1;
    background-color: #ffffff;
}

.loader-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 50px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 1000;
    transition: transform 0.3s, opacity 0.3s;
}

.loader-container.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

.loader-container p {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(66, 153, 225, 0.2);
    border-top-color: #4299e1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.columns-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.hidden {
    opacity: 0;
    pointer-events: none;
    position: absolute;
}

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    overflow: hidden;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.col-header {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.col-header h2 {
    margin: 0;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-input {
    padding: 0.5rem 0.8rem;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    width: 100%;
    box-sizing: border-box;
    background: rgba(255,255,255,0.6);
    transition: all 0.2s;
}

.filter-input:focus {
    outline: none;
    background: white;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.2);
}

.matched-header h2 { color: #ed8936; }
.favorites-header h2 { color: var(--accent-favorites); }
.projects-header h2 { color: var(--accent-projects); }
.personnel-header h2 { color: var(--accent-personnel); }
.others-header h2 { color: var(--accent-others); }

.badge {
    background: white;
    padding: 0.2rem 0.8rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.matched-header .badge { color: #ed8936; }
.favorites-header .badge { color: var(--accent-favorites); }
.projects-header .badge { color: var(--accent-projects); }
.personnel-header .badge { color: var(--accent-personnel); }
.others-header .badge { color: var(--accent-others); }

.email-list {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.email-list::-webkit-scrollbar {
    width: 6px;
}
.email-list::-webkit-scrollbar-track {
    background: transparent;
}
.email-list::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
}

.email-card {
    background: white;
    border-radius: 12px;
    padding: 1.2rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
    cursor: pointer;
    position: relative;
}

.card-index {
    position: absolute;
    top: 6px;
    left: 8px;
    font-size: 0.72rem;
    color: rgba(0,0,0,0.12);
    font-weight: 800;
    pointer-events: none;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}

.email-card:hover .card-index {
    color: rgba(0,0,0,0.5);
    transform: scale(1.1);
}


.email-card.favorite {
    background-color: #fefcbf !important; /* Light Yellow */
    border-color: #ecc94b !important;
}

.email-card.matched {
    background-color: #c6f6d5 !important; /* Light Green */
    border-color: #48bb78 !important;
}

.email-card.read {
    opacity: 0.75;
    background: rgba(255, 255, 255, 0.7) !important;
}

/* Priority: Matched color should win if both exist */
.email-card.favorite.matched {
    background-color: #c6f6d5 !important;
}

.email-card.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.drag-over-active {
    opacity: 0.9;
    transform: scale(0.99);
}

#col-matched.drag-over-active {
    background-color: rgba(237, 137, 54, 0.05) !important;
    border: 2px dashed #ed8936 !important;
}

#col-favorites.drag-over-active {
    background-color: rgba(214, 158, 46, 0.05) !important;
    border: 2px dashed var(--accent-favorites) !important;
}

#col-projects.drag-over-active {
    background-color: rgba(66, 153, 225, 0.05) !important;
    border: 2px dashed var(--accent-projects) !important;
}

#col-personnel.drag-over-active {
    background-color: rgba(72, 187, 120, 0.05) !important;
    border: 2px dashed var(--accent-personnel) !important;
}

#col-others.drag-over-active {
    background-color: rgba(159, 122, 234, 0.05) !important;
    border: 2px dashed var(--accent-others) !important;
}

#col-matched .email-card:hover { border-left-color: #ed8936; transform: translateX(4px); box-shadow: 0 6px 12px rgba(237, 137, 54, 0.1); }
#col-favorites .email-card:hover { border-left-color: var(--accent-favorites); transform: translateX(4px); box-shadow: 0 6px 12px rgba(214, 158, 46, 0.1); }
#col-projects .email-card:hover { border-left-color: var(--accent-projects); transform: translateX(4px); box-shadow: 0 6px 12px rgba(66, 153, 225, 0.1); }
#col-personnel .email-card:hover { border-left-color: var(--accent-personnel); transform: translateX(4px); box-shadow: 0 6px 12px rgba(72, 187, 120, 0.1); }
#col-others .email-card:hover { border-left-color: var(--accent-others); transform: translateX(4px); box-shadow: 0 6px 12px rgba(159, 122, 234, 0.1); }

.card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
    align-items: center;
}

.sender, .date {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.drag-handle {
    cursor: grab;
    color: #cbd5e0;
}
.drag-handle:active {
    cursor: grabbing;
}

.sender {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

.subject {
    margin: 0 0 0.5rem 0;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;  
    overflow: hidden;
}

.snippet {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;  
    overflow: hidden;
}

.meta-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.fav-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #cbd5e0;
    font-size: 1.1rem;
    padding: 0;
    transition: color 0.2s, transform 0.2s;
}

.fav-btn:hover {
    color: var(--accent-favorites);
    transform: scale(1.1);
}

.fav-btn.active {
    color: var(--accent-favorites);
}
.fav-btn.active i {
    font-weight: 900;
}

.card-tool-btn {
    background: none;
    border: none;
    padding: 6px;
    margin-right: 6px;
    color: #cbd5e0;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    line-height: normal;
}
.hide-btn:hover {
    color: #f56565 !important;
    transform: scale(1.2);
}



.card-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed rgba(0, 0, 0, 0.05);
}

.card-footer .date {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.card-footer .date i {
    margin-right: 4px;
    opacity: 0.7;
}



.date-divider {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    margin: 1.5rem 0 0.5rem 0;
}

.date-divider::before, .date-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px dashed rgba(0,0,0,0.15);
}

.date-divider span {
    padding: 0 10px;
}

/* ===== Email Modal (split-pane) ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    box-sizing: border-box;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.2s ease;
}

#email-modal {
    z-index: 10000;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    position: fixed;
}

.modal-container {
    background: #f0f4f8;
    border-radius: 16px;
    width: 100%;
    max-width: 1400px;
    height: calc(100vh - 3rem);
    box-shadow: 0 24px 64px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: row;
    overflow: hidden;
    animation: modal-in 0.22s ease;
}

@keyframes modal-in {
    from { transform: translateY(-16px); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

/* ---- Panes ---- */
.modal-pane {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-pane-left {
    flex: 1;
    background: white;
    border-right: 1px solid #e2e8f0;
    min-width: 0;
}

.modal-pane-right {
    width: 380px;
    flex-shrink: 0;
    background: #f7fafc;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ---- Header (left pane) ---- */
.modal-header {
    background: #edf2f7;
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
    position: relative; /* Base for absolute buttons */
}

.modal-header-buttons {
    position: absolute;
    top: 1.2rem;
    right: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 10;
}


.modal-header-top {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    margin-bottom: 0.6rem;
}

.modal-header h2,
.modal-subject {
    margin: 0;
    font-size: 1.15rem;
    color: #1a202c;
    flex: 1;
    line-height: 1.4;
    padding-right: 120px; /* Stay away from buttons */
}



.modal-fav-btn,
.modal-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.3rem;
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s, transform 0.15s;
    flex-shrink: 0;
}

.modal-fav-btn { color: #cbd5e0; }
.modal-fav-btn:hover { color: var(--accent-favorites); transform: scale(1.15); }
.modal-fav-btn.active { color: var(--accent-favorites); }

.modal-close-btn { color: #718096; }
.modal-close-btn:hover { background: #fed7d7; color: #e53e3e; }

.modal-meta {
    font-size: 0.85rem;
    color: #4a5568;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.3rem;
}

/* ---- Scrollable body ---- */
.modal-body-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.modal-body-content {
    margin: 0;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.88rem;
    white-space: pre-wrap;
    line-height: 1.75;
    color: #2d3748;
    word-break: break-word;
}

/* ---- Right pane: sidebar view ---- */
#modal-sidebar-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
}

.modal-sidebar {
    padding: 1.2rem;
}

.modal-sidebar:empty::after {
    content: 'マッチする要員なし';
    display: block;
    text-align: center;
    color: #a0aec0;
    font-size: 0.9rem;
    margin-top: 2rem;
}

.modal-sidebar-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #2b6cb0;
    margin: 0 0 0.8rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e2e8f0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.modal-match-card {
    background: white;
    padding: 0.9rem;
    border-radius: 8px;
    margin-bottom: 0.8rem;
    border-left: 4px solid #48bb78;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.modal-match-card:hover {
    transform: translateX(3px);
    box-shadow: 0 4px 12px rgba(72,187,120,0.2);
}

.modal-match-card .match-subject {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    color: #2d3748;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.modal-match-card .match-snippet {
    font-size: 0.78rem;
    color: #718096;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.modal-match-card .match-open {
    font-size: 0.75rem;
    color: #48bb78;
    margin-top: 0.4rem;
    font-weight: 600;
}

/* ---- Right pane: match detail view ---- */
#modal-match-detail {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

#modal-match-detail.hidden {
    display: none;
}

.modal-match-detail-header {
    background: #e6fffa;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid #b2f5ea;
    flex-shrink: 0;
}

.modal-back-btn {
    background: none;
    border: 1px solid #68d391;
    color: #276749;
    border-radius: 6px;
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 0.6rem;
    transition: background 0.15s;
    font-family: inherit;
}

.modal-back-btn:hover {
    background: #c6f6d5;
}

.modal-match-detail-subject {
    margin: 0 0 0.4rem 0;
    font-size: 0.95rem;
    color: #1a202c;
    line-height: 1.4;
}

.modal-match-detail-meta {
    font-size: 0.8rem;
    color: #4a5568;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.3rem;
}

/* Right pane label */
.modal-pane-right-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #a0aec0;
    text-align: center;
    padding: 0.6rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f7fafc;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    flex-shrink: 0;
}

/* ===== Notifications ===== */
.notification-area {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.notification {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slide-in 0.3s ease-out;
    min-width: 300px;
}

.notification.success {
    border-left: 4px solid #10b981;
}

.notification.error {
    border-left: 4px solid #ef4444;
}

.notification i {
    font-size: 1.25rem;
}

.notification.success i {
    color: #10b981;
}

.notification.error i {
    color: #ef4444;
}

@keyframes slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.add-col-btn {
    background: rgba(66, 153, 225, 0.15);
    border: none;
    color: #4299e1;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.add-col-btn:hover {
    background: #4299e1;
    color: white;
    transform: scale(1.1);
}

