:root {
    /* Light Theme */
    --bg-color: #f8fafc;
    --bg-main: #f8fafc;
    --surface-color: rgba(255, 255, 255, 0.8);
    --header-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --border-color: #e2e8f0;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --glass-border: rgba(0, 0, 0, 0.1);
    --account-name-color: #000000;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] {
    --bg-color: #0f172a;
    --bg-main: #0f172a;
    --surface-color: rgba(30, 41, 59, 0.7);
    --header-bg: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --primary-color: #3b82f6;
    --primary-hover: #60a5fa;
    --glass-border: rgba(255, 255, 255, 0.1);
    --account-name-color: var(--primary-color);
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
    padding-bottom: 4rem;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.logo span {
    font-weight: 400;
    font-size: 1.2rem;
}

/* Logo handled by JS theme script */

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    font-size: 1.2rem;
    cursor: pointer;
    width: 2.2rem;
    height: 2.2rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-primary);
    transition: all 0.2s;
}
.btn-icon:hover {
    background: var(--border-color);
}

/* Header Controls & Account Selector */
.header-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.account-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(59, 130, 246, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.account-selector label {
    margin: 0;
    font-size: 0.85rem;
    color: var(--primary-color);
    font-weight: 600;
}

.account-selector select {
    background: transparent;
    border: none;
    padding: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
    width: auto;
    box-shadow: none;
}
.account-selector select:focus {
    box-shadow: none;
}

/* App Layout (Sidebar + Main Content) */
.app-layout {
    display: flex;
    width: 100%;
    min-height: calc(100vh - 80px); /* 80px is approx header height */
}

/* Sidebar */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 1rem;
    position: sticky;
    top: 80px;
    height: calc(100vh - 80px);
    overflow-y: auto;
    background: var(--surface-color);
}

.nav-group {
    margin-bottom: 2rem;
}

.nav-group-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    padding-left: 0.75rem;
    letter-spacing: 0.05em;
}

.nav-item {
    display: block;
    padding: 0.6rem 0.75rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 0.5rem;
    margin-bottom: 0.25rem;
    transition: all 0.2s ease;
}

.nav-item:hover {
    background: rgba(59, 130, 246, 0.05);
    color: var(--primary-color);
}

.nav-item.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary-color);
    font-weight: 600;
    border-left: 3px solid var(--primary-color);
}



/* Main Content Container */
.main-content {
    flex: 1;
    padding: 2rem 2.5rem;
    width: 100%;
    box-sizing: border-box;
}

/* Cards & Glassmorphism */
.card {
    background: var(--surface-color);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

h2 {
    margin-bottom: 1rem;
    font-size: 1.15rem;
    font-weight: 600;
}
h3 {
    margin: 1.5rem 0 0.5rem;
    font-size: 1.1rem;
    color: var(--primary-color);
}

p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}
label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}
.required {
    color: var(--danger-color);
}
input, select {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
input[type="checkbox"] {
    width: 14px;
    height: 14px;
    padding: 0;
    margin: 0;
    cursor: pointer;
    border-radius: 3px;
    border: 1px solid var(--border-color);
}
input[type="checkbox"]:focus {
    box-shadow: none;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-success, .btn-danger {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}
.btn-primary {
    background: var(--primary-color);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}
.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: var(--border-color);
}

/* Grid for Results */
.results-split-layout {
    display: flex;
    gap: 2rem;
    align-items: start;
    width: 100%;
}
.refinement-sidebar {
    width: 320px;
    flex-shrink: 0;
    position: sticky;
    top: 104px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3);
}
@media (max-width: 1024px) {
    .results-split-layout {
        flex-direction: column-reverse;
    }
    .refinement-sidebar {
        width: 100% !important;
        position: static !important;
        box-shadow: none;
    }
}
.asset-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}
@media (max-width: 768px) {
    .asset-grid {
        grid-template-columns: 1fr;
    }
}
.asset-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 0.5rem 0.8rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.4rem;
}
.asset-text {
    font-weight: 500;
    margin-bottom: 0.3rem;
    font-size: 1.05rem;
}
.asset-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}
.tag {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-secondary);
    border-radius: 1rem;
    margin-right: 0.25rem;
    font-weight: 600;
}

/* 4P Tags (Google Colors) */
.tag-product { background: rgba(234, 67, 53, 0.1) !important; color: #EA4335 !important; }
.tag-price { background: rgba(251, 188, 5, 0.15) !important; color: #F9AB00 !important; }
.tag-place { background: rgba(52, 168, 83, 0.1) !important; color: #34A853 !important; }
.tag-promotion { background: rgba(66, 133, 244, 0.1) !important; color: #4285F4 !important; }

/* Dark mode brightness adjustments for Google Colors */
[data-theme="dark"] .tag-product { color: #F28B82 !important; }
[data-theme="dark"] .tag-price { color: #FDD663 !important; }
[data-theme="dark"] .tag-place { color: #81C995 !important; }
[data-theme="dark"] .tag-promotion { color: #8AB4F8 !important; }

.feedback-actions {
    display: flex;
    gap: 0.5rem;
}
.feedback-btn {
    flex: 1;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-primary);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}
.feedback-btn:hover {
    background: var(--border-color);
}
.feedback-btn.active-approve {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--success-color);
    color: var(--success-color);
}
.feedback-btn.active-reject {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger-color);
    color: var(--danger-color);
}

/* Utility Classes */
.hidden { display: none !important; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1.5rem; }

/* Loading Spinner */
.loading {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    color: var(--text-secondary);
}
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Chart loading overlay (shared across all agents) */
.chart-loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(17, 26, 46, 0.78);
    z-index: 5;
    border-radius: 8px;
}
.chart-loading-spinner {
    width: 28px;
    height: 28px;
    border: 2.5px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
.chart-loading-message {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* CVグループフィルタ（全エージェント agent-header 右側に統一） */
.agent-cv-group-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.agent-cv-group-filter-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    margin-bottom: 0;
}
.agent-cv-group-filter-select {
    padding: 4px 12px;
    font-size: 0.8rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-weight: 600;
    outline: none;
    cursor: pointer;
    height: 28px;
    line-height: 1;
    min-width: 180px;
    max-width: 280px;
}
.agent-header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Score Badge */
.score-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 1rem;
    margin-bottom: 0.5rem;
    align-self: flex-start;
}
.score-high { background: rgba(16, 185, 129, 0.15); color: #059669; }
.score-medium { background: rgba(245, 158, 11, 0.15); color: #d97706; }
.score-low { background: rgba(239, 68, 68, 0.15); color: #dc2626; }
[data-theme="dark"] .score-high { color: #34d399; }
[data-theme="dark"] .score-medium { color: #fbbf24; }
[data-theme="dark"] .score-low { color: #f87171; }

/* Animations */
.fade-in {
    animation: fadeIn 0.4s ease forwards;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    display: none;
    opacity: 0;
}

.modal-content {
    background: var(--bg-color);
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-content .modal-body {
    overflow-y: auto;
    flex: 1;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* --- Multi-View SPA Styles --- */
.view-container {
    animation: fadeIn 0.3s ease;
}
.view-container.hidden {
    display: none !important;
}

/* Login Box */
.login-box {
    max-width: 400px;
    margin: 10vh auto;
    padding: 3rem 2rem;
}

/* Account Grid */
.account-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
}

.account-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 300px;
}
.account-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
    border-color: var(--primary-color);
}
.account-card h3 {
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
}
.account-card p {
    margin: 0;
    font-size: 0.9rem;
}

/* Agent Grid & Cards */
.agent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(460px, 1fr));
    gap: 1.5rem;
}

.agent-card {
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem;
    cursor: pointer;
    position: relative;
    align-items: flex-start;
}
.agent-card:hover:not(.disabled) {
    transform: translateY(-4px);
    border-color: var(--primary-color);
}
.agent-card.disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.agent-card-icon {
    font-size: 2.5rem;
    background: rgba(59, 130, 246, 0.1);
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    flex-shrink: 0;
}

.agent-card-content h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}
.agent-card-content p {
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.4;
}

.global-quota-notice {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin: 0 0 16px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.08);
    color: var(--text-primary);
    font-size: 0.82rem;
    line-height: 1.55;
    box-sizing: border-box;
}

.global-quota-notice--limited {
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.08);
}

.global-quota-notice__body {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.global-quota-notice__icon {
    line-height: 1.2;
    flex-shrink: 0;
}

.global-quota-notice__close {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    flex-shrink: 0;
}

.dashboard-pending-approval-banner {
    border: 1px solid rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.04);
}

.dashboard-pending-approval-banner__inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.dashboard-pending-approval-banner__title {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.55;
    color: var(--text-primary);
    font-weight: 600;
}

.dashboard-pending-approval-banner__desc {
    margin: 6px 0 0;
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.dashboard-pending-approval-banner__cta {
    margin-bottom: 0;
    white-space: nowrap;
}

/* Notification Badge & Popup */
.notification-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    background: var(--danger-color);
    color: white;
    font-size: 0.8rem;
    font-weight: bold;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 10;
}

.notification-popup {
    position: absolute;
    top: 30px;
    right: -10px;
    background: var(--surface-color);
    border: 1px solid var(--danger-color);
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
    width: 280px;
    z-index: 20;
    backdrop-filter: blur(10px);
}
.notification-popup h4 {
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
    font-size: 0.95rem;
}
.notification-popup p {
    font-size: 0.85rem;
    margin-bottom: 1rem;
}
.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

/* --- Keyword Agent UI Component Styles --- */
.word-cloud-container {
    background: rgba(30, 41, 59, 0.4) !important;
    border: 1px dashed var(--border-color) !important;
    min-height: 140px;
    padding: 1.5rem !important;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: flex-start !important;
    align-items: center;
}

.word-tag {
    display: inline-block;
    padding: 0.4rem 2.2rem 0.4rem 0.8rem !important;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid transparent;
    position: relative;
}
.word-tag:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    filter: brightness(1.15);
}
.word-tag .delete-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.15);
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    cursor: pointer;
}
.word-tag:hover .delete-btn {
    opacity: 1;
}
.word-tag .delete-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #ffffff;
}

/* Tag category colors */
.word-tag.relevance-tag {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.25);
}
.word-tag.ctr-tag {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.25);
}
.word-tag.lp-tag {
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.25);
}
.word-tag.query-tag {
    background: rgba(139, 92, 246, 0.12);
    color: #a78bfa;
    border-color: rgba(139, 92, 246, 0.25);
}

[data-theme="light"] .word-tag.relevance-tag {
    background: rgba(239, 68, 68, 0.08);
    color: #b91c1c;
    border-color: rgba(239, 68, 68, 0.15);
}
[data-theme="light"] .word-tag.ctr-tag {
    background: rgba(245, 158, 11, 0.08);
    color: #b45309;
    border-color: rgba(245, 158, 11, 0.15);
}
[data-theme="light"] .word-tag.lp-tag {
    background: rgba(16, 185, 129, 0.08);
    color: #047857;
    border-color: rgba(16, 185, 129, 0.15);
}
[data-theme="light"] .word-tag.query-tag {
    background: rgba(139, 92, 246, 0.08);
    color: #6d28d9;
    border-color: rgba(139, 92, 246, 0.15);
}

/* Quality components sub-badges */
.component-badge {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 0.25rem;
    text-transform: uppercase;
}
.component-above {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
}
.component-average {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
}
.component-below {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

[data-theme="light"] .component-above {
    background: rgba(16, 185, 129, 0.08);
    color: #047857;
}
[data-theme="light"] .component-average {
    background: rgba(245, 158, 11, 0.08);
    color: #b45309;
}
[data-theme="light"] .component-below {
    background: rgba(239, 68, 68, 0.08);
    color: #b91c1c;
}

/* Toast/Notification design */
.toast-msg {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    border-radius: 0.6rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 2000;
    animation: slideUp 0.3s ease forwards;
}
.toast-success {
    border-color: var(--success-color);
    color: var(--success-color);
}
.toast-error {
    border-color: var(--danger-color);
    color: var(--danger-color);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Word cloud collapse styling */
.word-cloud-container {
    transition: max-height 0.3s ease;
}
.word-cloud-container.collapsed {
    max-height: 195px !important;
    overflow: hidden !important;
}
.show-more-toggle {
    text-align: center;
    margin-top: 0.75rem;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    user-select: none;
    transition: color 0.2s;
}
.show-more-toggle:hover {
    color: var(--primary-hover);
}

/* App Footer */
.app-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 1.5rem 2rem;
    background: var(--header-bg);
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: auto;
    width: 100%;
}

.unknown-footer-logo {
    height: 24px;
    width: auto;
    object-fit: contain;
    border-radius: 2px;
    opacity: 0.8;
    transition: opacity 0.2s, filter 0.2s;
}

.unknown-footer-logo:hover {
    opacity: 1;
}

/* Dark Mode Logo Inversion */
[data-theme="dark"] .unknown-footer-logo {
    filter: invert(1) brightness(1.2);
}

/* --- Budget Allocation Planner Specific Styles --- */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper.JPY::after {
    content: "円";
    position: absolute;
    right: 14px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.input-wrapper.JPY input {
    padding-right: 36px;
}

/* Config Panel Summary */
details.config-panel {
    display: block;
    padding: 0 !important;
    overflow: visible;
    margin-bottom: 20px;
    transition: all 0.3s ease;
    position: relative;
    width: 100%;
}

.panel-summary {
    list-style: none;
    outline: none;
    cursor: pointer;
    padding: 18px 24px;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

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

.panel-summary:hover {
    background: rgba(255, 255, 255, 0.02);
}

.config-panel[open] .panel-summary {
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.01);
}

.panel-summary-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.1rem;
    font-weight: 600;
}

.panel-summary-title .icon {
    font-size: 1.3rem;
    color: var(--primary-color);
}

.panel-summary::after {
    content: "▼";
    position: absolute;
    right: 24px;
    top: 20px;
    font-size: 0.8rem;
    transition: transform 0.2s ease;
    color: var(--text-secondary);
}

.config-panel[open] .panel-summary::after {
    transform: rotate(180deg);
}

.panel-form {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.config-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 24px;
}

/* Agency Mode Toggle & Visibility Control */
.agency-only {
    display: none !important;
}

.agency-mode-active .agency-only {
    display: block !important;
}

/* Campaign Directory Table Styles */
.campaign-directory-container {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.01);
    margin-top: 8px;
}

.campaign-directory-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.campaign-directory-table th {
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1;
}

.campaign-directory-table td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
    color: var(--text-primary);
}

.campaign-directory-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.campaign-directory-table select,
.campaign-directory-table input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 0.75rem;
    width: 100%;
    box-sizing: border-box;
}

.campaign-directory-table input[type="number"] {
    max-width: 90px;
}

.campaign-directory-table td.camp-name-cell {
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


.config-card {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.config-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 4px;
}

/* Campaign Individual Rule Grid */
.rules-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rule-item {
    display: grid;
    grid-template-columns: 2.2fr 1fr 1fr 1fr 1.2fr;
    gap: 8px;
    align-items: center;
    padding: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.8rem;
}

.rule-item-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.rule-item input, .rule-item select {
    padding: 6px 8px;
    font-size: 0.75rem;
    border-radius: 6px;
}

/* Media Sub Accordions */
details.media-accordion {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
    background: rgba(255, 255, 255, 0.01);
    transition: all 0.2s ease;
}

details.media-accordion[open] {
    background: rgba(255, 255, 255, 0.02);
}

details.media-accordion summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--primary-color);
    list-style: none;
    outline: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

details.media-accordion summary::-webkit-details-marker {
    display: none;
}

details.media-accordion summary::after {
    content: "▼";
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    color: var(--text-secondary);
}

details.media-accordion[open] summary::after {
    transform: rotate(180deg);
}

.accordion-content {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* AI Assistant & Feedbacks */
.ai-assistant textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 12px;
    font-size: 0.85rem;
    resize: none;
    font-family: inherit;
    line-height: 1.5;
    transition: all 0.2s ease;
}

.ai-assistant textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.ai-feedback {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.feedback-block {
    padding: 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    line-height: 1.4;
}

.feedback-block h4 {
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.feedback-block ul {
    margin: 0;
    padding-left: 16px;
}

.feedback-block li {
    margin-bottom: 4px;
}

.feedback-block.warnings {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.feedback-block.suggestions {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

[data-theme="light"] .feedback-block.warnings {
    background: rgba(239, 68, 68, 0.05);
    color: #b91c1c;
}

[data-theme="light"] .feedback-block.suggestions {
    background: rgba(245, 158, 11, 0.05);
    color: #b45309;
}

/* KPI Subtitles Colors */
.kpi-sub.up {
    color: var(--success-color) !important;
}

.kpi-sub.down {
    color: var(--danger-color) !important;
}

/* Chart Styles */
.chart-toggle-group button {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    transition: all 0.2s;
}

.chart-toggle-group button.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-weight: 600;
}

[data-theme="light"] .chart-toggle-group button.active {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-primary);
}

/* Table Today Highlight (Light Theme / Default) */
.table-today td {
    background: rgba(16, 185, 129, 0.08) !important; /* Highly visible soft green background */
    font-weight: 700;
    color: #065f46 !important; /* Premium dark emerald text for high contrast */
    border-top: 1.5px solid rgba(16, 185, 129, 0.4) !important;
    border-bottom: 1.5px solid rgba(16, 185, 129, 0.4) !important;
}

.table-today td:first-child {
    border-left: 1.5px solid rgba(16, 185, 129, 0.4) !important;
}

.table-today td:last-child {
    border-right: 1.5px solid rgba(16, 185, 129, 0.4) !important;
}

.table-today td:not(:first-child):not(:last-child) {
    border-left: 1px solid rgba(16, 185, 129, 0.12) !important;
    border-right: 1px solid rgba(16, 185, 129, 0.12) !important;
}

/* Table Today Highlight (Dark Theme) */
[data-theme="dark"] .table-today td {
    background: rgba(16, 185, 129, 0.12) !important; /* Solid dark green highlight */
    color: #ffffff !important; /* Highly legible white text */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); /* Soft shadow for text protection */
    border-top: 1.5px solid rgba(16, 185, 129, 0.6) !important;
    border-bottom: 1.5px solid rgba(16, 185, 129, 0.6) !important;
}

[data-theme="dark"] .table-today td:first-child {
    border-left: 1.5px solid rgba(16, 185, 129, 0.6) !important;
}

[data-theme="dark"] .table-today td:last-child {
    border-right: 1.5px solid rgba(16, 185, 129, 0.6) !important;
}

[data-theme="dark"] .table-today td:not(:first-child):not(:last-child) {
    border-left: 1px solid rgba(16, 185, 129, 0.18) !important;
    border-right: 1px solid rgba(16, 185, 129, 0.18) !important;
}

/* Badges for campaigns in Table */
.badge {
    display: inline-block;
    padding: 2px 6px;
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-search { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.badge-pmax { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }
.badge-video { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.badge-display { background: rgba(16, 185, 129, 0.1); color: #10b981; }

.badge-auto { background: rgba(148, 163, 184, 0.1); color: var(--text-secondary); }
.badge-fixed { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.badge-boost { background: rgba(236, 72, 153, 0.1); color: #ec4899; }

/* Slider switch styles for agency mode */
.switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .3s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
}

input:checked + .slider {
    background-color: var(--primary-color, #3b82f6);
}

input:checked + .slider:before {
    transform: translateX(18px);
}

.slider.round {
    border-radius: 20px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Config Card Header with Title and Toggle */
.config-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 4px;
}

.config-card-header h3 {
    border-bottom: none !important;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

.agency-mode-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.agency-mode-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Margin settings wrapper for toggle animation */
.margin-settings-wrapper {
    transition: all 0.3s ease-in-out;
}

/* KPI grid styles */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.kpi-card {
    padding: 1.5rem !important;
    margin-bottom: 0 !important;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.kpi-header .icon {
    font-size: 1.2rem;
}

.kpi-value {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.kpi-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

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

/* --- Campaign Status Dot --- */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}
.status-dot.enabled {
    background-color: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}
.status-dot.paused {
    background-color: #f59e0b;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
}
.status-dot.removed, .status-dot.disabled {
    background-color: #ef4444;
}

/* --- Calendar picker inside modal --- */
.calendar-grid-container {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
}
.calendar-day-cell {
    padding: 8px 0;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s ease;
    user-select: none;
    font-weight: 500;
}
.calendar-day-cell:hover:not(.empty-cell) {
    background: rgba(255, 255, 255, 0.1);
}
.calendar-day-cell.empty-cell {
    cursor: default;
}
.calendar-day-cell.active-day {
    background: var(--primary-color) !important;
    color: white !important;
    font-weight: bold;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}
.calendar-day-cell.sat-day:not(.active-day) {
    color: #3b82f6;
}
.calendar-day-cell.sun-holiday-day:not(.active-day) {
    color: #ef4444;
}

/* --- Daily detail table colors --- */
#detail-table tr.sat-row td {
    color: #60a5fa !important;
    background-color: rgba(59, 130, 246, 0.05);
}
#detail-table tr.sun-holiday-row td {
    color: #f87171 !important;
    background-color: rgba(239, 68, 68, 0.05);
}

/* --- Double-row layout in campaign directory table --- */
.alloc-setting-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}
.alloc-setting-row {
    display: flex;
    align-items: center;
    width: 100%;
}
.slider-container {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}
.slider-container input[type="range"] {
    flex: 1;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    outline: none;
    accent-color: var(--primary-color);
}
.slider-container span {
    font-size: 0.75rem;
    font-weight: bold;
    min-width: 35px;
    text-align: right;
    color: var(--primary-color);
}.prod-filter-btn, .camp-filter-btn {
    background: transparent !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-secondary) !important;
    padding: 4px 10px !important;
    font-size: 0.75rem !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    border-radius: 4px !important;
    transition: all 0.2s ease !important;
}

.prod-filter-btn:hover, .camp-filter-btn:hover {
    color: var(--text-primary) !important;
    background: rgba(255, 255, 255, 0.04) !important;
}

/* Filter Tabs Active State (Light Theme / Default) */
.prod-filter-btn.active, .camp-filter-btn.active {
    color: white !important;
    background: var(--primary-color) !important; /* Premium active solid blue background for light theme */
    border-color: var(--primary-color) !important;
    font-weight: 600 !important;
}

/* Filter Tabs Active State (Dark Theme) */
[data-theme="dark"] .prod-filter-btn.active, [data-theme="dark"] .camp-filter-btn.active {
    color: white !important;
    background: rgba(255, 255, 255, 0.15) !important; /* Sleek frosted-glass effect for dark theme */
    border-color: var(--primary-color) !important;
    font-weight: 600 !important;
}

/* --- Daily detail table total row styling --- */
#detail-table tr.total-row td {
    font-weight: bold !important;
    background-color: rgba(255, 255, 255, 0.08) !important;
    border-top: 2px solid rgba(255, 255, 255, 0.15) !important;
    border-bottom: 2px solid rgba(255, 255, 255, 0.15) !important;
    color: var(--text-primary) !important;
}

/* Platform Badges & Logos */
.badge-platform {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
    margin-left: 0.5rem;
    display: inline-block;
    vertical-align: middle;
    line-height: 1;
}
.badge-google {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.25);
}
.badge-yahoo {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
    border: 1px solid rgba(139, 92, 246, 0.25);
}
[data-theme="dark"] .badge-google {
    background: rgba(96, 165, 250, 0.15);
    color: #93c5fd;
    border-color: rgba(96, 165, 250, 0.25);
}
[data-theme="dark"] .badge-yahoo {
    background: rgba(167, 139, 250, 0.15);
    color: #c4b5fd;
    border-color: rgba(167, 139, 250, 0.25);
}

/* Media Logos */
.badge-logo-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent !important;
    border: none !important;
    padding: 0;
    margin-left: 0.5rem;
    height: 30px;
    width: 30px;
    box-sizing: border-box;
    vertical-align: middle;
    transition: all 0.2s ease;
    flex-shrink: 0; /* Prevent title text from shrinking the logo */
}
.media-logo {
    height: 22px !important; /* Increased from 18px */
    width: 22px !important;  /* Increased from 18px */
    object-fit: contain;
    display: block;
}





/* Yahoo Account Card Hover */
.account-card.account-card-yahoo:hover {
    border-color: #8b5cf6 !important;
    box-shadow: 0 10px 15px -3px rgba(139, 92, 246, 0.15), 0 4px 6px -2px rgba(139, 92, 246, 0.1) !important;
}
[data-theme="dark"] .account-card.account-card-yahoo:hover {
    border-color: #a78bfa !important;
    box-shadow: 0 10px 15px -3px rgba(167, 139, 250, 0.2), 0 4px 6px -2px rgba(167, 139, 250, 0.15) !important;
}

/* Media Accordion */
.media-accordion {
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    margin-bottom: 1.5rem;
    overflow: hidden;
    background: var(--surface-color);
    box-shadow: var(--shadow);
}
.media-accordion-header {
    padding: 1.2rem 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 1.1rem;
    user-select: none;
    transition: background 0.2s ease;
    border-bottom: 1px solid transparent;
}
.media-accordion-header:hover {
    background: rgba(255, 255, 255, 0.05);
}
.media-accordion.open .media-accordion-header {
    border-bottom-color: var(--border-color);
    background: rgba(255, 255, 255, 0.03);
}
.media-accordion-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.media-accordion-arrow {
    transition: transform 0.2s ease;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.media-accordion.open .media-accordion-arrow {
    transform: rotate(180deg);
}
.media-accordion-content {
    padding: 1.5rem;
    display: none;
}
.media-accordion.open .media-accordion-content {
    display: block;
}

/* History Card & Item Styles */
.history-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.2s;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.12);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
}

.history-item-date {
    color: var(--text-secondary);
}

.history-item-source {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
}

.source-agent {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.source-web {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.history-item-body {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.8rem;
}

.history-item-camp {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

.history-item-change {
    font-weight: 600;
    font-size: 0.75rem;
}

.change-type-cpa { color: #60a5fa; }
.change-type-budget { color: #f472b6; }
.change-type-strat { color: #a78bfa; }

.history-item-values {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.history-item-values span.new-val {
    color: var(--text-primary);
    font-weight: bold;
}


/* --- Calendar Today Row Highlight --- */
.daily-today {
    background-color: rgba(16, 185, 129, 0.15) !important;
    border: 1px solid rgba(16, 185, 129, 0.6) !important;
}

/* Modal Overlay & Box */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.25s ease-out;
}

.modal-box {
    width: 100%;
    max-width: 440px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 28px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 14px;
}

.modal-header h3 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-instruction {
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text-primary);
}

/* Google Account Selection Card */
.google-account-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.google-account-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.account-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.account-details {
    display: flex;
    flex-direction: column;
}

.account-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.account-email {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* OAuth Scopes consent container */
.oauth-scopes-container {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.scopes-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.scope-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--text-primary);
}

.scope-checkbox-label input[type="checkbox"] {
    margin-top: 3px;
    cursor: pointer;
}

.modal-policy-text {
    font-size: 0.7rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleUp {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* --- Bidding Agent UI Styles --- */
.bidding-main-grid {
    display: grid;
    grid-template-columns: 1.4fr 0.6fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 1024px) {
    .bidding-main-grid {
        grid-template-columns: 1fr;
    }
}

.chart-with-comment-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    align-items: stretch;
    margin-top: 12px;
}

@media (max-width: 1024px) {
    .chart-with-comment-grid {
        grid-template-columns: 1fr;
    }
}

/* Allocator Main Grid Layout */
.allocator-main-grid {
    display: grid;
    grid-template-columns: 1.35fr 0.65fr;
    gap: 24px;
    width: 100%;
    align-items: start;
}

@media (max-width: 1024px) {
    .allocator-main-grid {
        grid-template-columns: 1fr;
    }
}

/* Account Group Grid Layout */
.account-group-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 24px;
    width: 100%;
    align-items: start;
}

@media (max-width: 1024px) {
    .account-group-grid {
        grid-template-columns: 1fr;
    }
}

/* Time Main Grid Layout */
.time-main-grid {
    display: grid;
    grid-template-columns: 1.35fr 0.65fr;
    gap: 24px;
    width: 100%;
    align-items: start;
}

@media (max-width: 1024px) {
    .time-main-grid {
        grid-template-columns: 1fr;
    }
}

/* Simulator Grid Layout */
.simulator-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .simulator-grid {
        grid-template-columns: 1fr;
    }
}

.hidden {
    display: none !important;
}

/* Mode Select Cards */
.mode-select-card {
    border: 2px solid var(--border-color);
    background: transparent;
    padding: 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.mode-select-card:hover {
    border-color: rgba(59, 130, 246, 0.4);
    background: rgba(255, 255, 255, 0.02);
    transform: translateY(-2px);
}

.mode-select-card.active {
    border-color: var(--primary) !important;
    background: rgba(59, 130, 246, 0.08) !important;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.15);
}

/* Step Indicators */
.step-indicator {
    transition: all 0.3s ease;
}

/* 入札戦略改善 / クリエイティブ改善 — 共通ウィザードステップ */
.wizard-steps-header.agent-wizard-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    position: relative;
}

.wizard-steps-header.agent-wizard-steps .wizard-progress-bar {
    position: absolute;
    top: 12px;
    left: 12%;
    right: 12%;
    height: 2px;
    background: rgba(255, 255, 255, 0.08);
    z-index: 1;
}

.wizard-steps-header.agent-wizard-steps.steps-3 .wizard-progress-bar {
    left: 16%;
    right: 16%;
}

.wizard-steps-header.agent-wizard-steps .wizard-progress-active {
    width: 0%;
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
}

.wizard-steps-header.agent-wizard-steps .step-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 2;
    flex: 1;
    min-width: 0;
}

.wizard-steps-header.agent-wizard-steps.steps-3 .step-indicator {
    max-width: 33.333%;
}

.wizard-steps-header.agent-wizard-steps.steps-4 .step-indicator {
    max-width: 25%;
}

.wizard-steps-header.agent-wizard-steps .step-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.wizard-steps-header.agent-wizard-steps .step-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    text-align: center;
    line-height: 1.35;
}

.wizard-steps-header.agent-wizard-steps .step-indicator.active .step-num {
    background: var(--primary);
    color: white;
    border-color: var(--bg-primary);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.6);
}

.wizard-steps-header.agent-wizard-steps .step-indicator.active .step-label {
    color: var(--text-primary);
    font-weight: bold;
}

.wizard-steps-header.agent-wizard-steps .step-indicator.completed .step-num {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.wizard-steps-header.agent-wizard-steps .step-indicator.completed .step-label {
    color: var(--success);
}

.step-indicator.active .step-num {
    background-color: var(--primary) !important;
    color: white !important;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.6);
    border-color: var(--primary) !important;
}

.step-indicator.active .step-label {
    color: var(--text-primary) !important;
    font-weight: 600 !important;
}

.step-indicator.completed .step-num {
    background-color: var(--success) !important;
    color: white !important;
    border-color: var(--success) !important;
}

.step-indicator.completed .step-label {
    color: var(--success) !important;
}

/* AI Advisor Chat bubbles */
.chat-bubble {
    max-width: 85%;
    font-size: 0.8rem;
    line-height: 1.5;
    padding: 12px;
    border-radius: 12px;
    animation: fadeInBubble 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-bubble.advisor-bubble {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px 12px 12px 0;
    color: var(--text-primary);
}

.chat-bubble.user-bubble {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-radius: 12px 12px 0 12px;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

@keyframes fadeInBubble {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-chip-btn {
    transition: all 0.2s ease;
}

.chat-chip-btn:hover {
    background: rgba(59, 130, 246, 0.15) !important;
    border-color: var(--primary) !important;
    transform: scale(1.02);
}

/* Console logs & Terminal */
#terminal-log-output::-webkit-scrollbar {
    width: 6px;
}

#terminal-log-output::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.terminal-log-line {
    font-family: monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    padding: 2px 0;
    animation: printLine 0.1s ease;
}

@keyframes printLine {
    from { opacity: 0; }
    to { opacity: 1; }
}

.log-info { color: #94a3b8; }
.log-success { color: #10b981; font-weight: bold; }
.log-warn { color: #f59e0b; }
.log-error { color: #ef4444; font-weight: bold; }
.log-system { color: #60a5fa; }

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.9); }
}

/* Campaign Validation Highlight Warning */
.warning-highlight {
    border: 1px solid rgba(245, 158, 11, 0.5) !important;
    background: rgba(245, 158, 11, 0.05) !important;
    animation: flashBorder 2s infinite alternate;
}

@keyframes flashBorder {
    0% { border-color: rgba(245, 158, 11, 0.3); }
    100% { border-color: rgba(245, 158, 11, 0.8); }
}

.warning-indicator-box {
    margin-top: 6px;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: var(--warning);
    font-size: 0.75rem;
    line-height: 1.3;
}

.bidding-campaign-detail-link {
    transition: color 0.2s ease, text-shadow 0.2s ease;
}

.bidding-campaign-detail-link:hover {
    color: #60a5fa !important;
    text-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
    text-decoration: underline !important;
}

.btn-graph-shortcut {
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
    margin-right: 6px;
    margin-top: 6px;
}

.btn-graph-shortcut:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-graph-shortcut:active {
    transform: translateY(0);
}

/* Metrics Pill Selector */
.metric-pills-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0;
}

.metric-pill {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #94a3b8;
    padding: 6px 14px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 20px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.metric-pill:hover {
    color: #f1f5f9;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.metric-pill.active {
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    border-color: currentColor;
    background: rgba(255, 255, 255, 0.05);
}

.metric-pill[data-metric="cvr"].active { border-color: #10b981; color: #10b981; background: rgba(16, 185, 129, 0.1); }
.metric-pill[data-metric="top_is"].active { border-color: #3b82f6; color: #3b82f6; background: rgba(59, 130, 246, 0.1); }
.metric-pill[data-metric="cpa"].active { border-color: #f43f5e; color: #f43f5e; background: rgba(244, 63, 94, 0.1); }
.metric-pill[data-metric="cpc"].active { border-color: #eab308; color: #eab308; background: rgba(234, 179, 8, 0.1); }
.metric-pill[data-metric="budget"].active { border-color: #a855f7; color: #a855f7; background: rgba(168, 85, 247, 0.1); }
.metric-pill[data-metric="cost"].active { border-color: #06b6d4; color: #06b6d4; background: rgba(6, 182, 212, 0.1); }
.metric-pill[data-metric="impressions"].active { border-color: #ec4899; color: #ec4899; background: rgba(236, 72, 153, 0.1); }
.metric-pill[data-metric="ctr"].active { border-color: #84cc16; color: #84cc16; background: rgba(132, 204, 22, 0.1); }
.metric-pill[data-metric="lost_is"].active { border-color: #f97316; color: #f97316; background: rgba(249, 115, 22, 0.1); }
.metric-pill[data-metric="cv"].active { border-color: #6366f1; color: #6366f1; background: rgba(99, 102, 241, 0.1); }

.metric-pill .axis-badge {
    font-size: 0.62rem;
    padding: 1px 5px;
    border-radius: 4px;
    background: currentColor;
    color: #121824;
    font-weight: 800;
}

/* ==========================================================================
   CV Group Setup & Funnel Designer Style System
   ========================================================================== */

/* Designer Layout Grid */
.cv-designer-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 24px;
    align-items: start;
    width: 100%;
}

@media (max-width: 1024px) {
    .cv-designer-grid {
        grid-template-columns: 1fr;
    }
    .cv-palette-panel {
        position: static !important;
        max-height: none !important;
    }
}

/* Filter Tabs */
.cv-filter-tabs .filter-tab {
    padding: 5px 10px;
    font-size: 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.cv-filter-tabs .filter-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.cv-filter-tabs .filter-tab.active {
    color: #ffffff;
    background: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* Filter Specific Hover States for Inactive Tabs */
.cv-filter-tabs .filter-tab[data-filter="google"]:hover { border-color: rgba(59, 130, 246, 0.4); color: #3b82f6; }
.cv-filter-tabs .filter-tab[data-filter="yahoo"]:hover { border-color: rgba(239, 68, 68, 0.4); color: #ef4444; }
.cv-filter-tabs .filter-tab[data-filter="ga4"]:hover { border-color: rgba(249, 115, 22, 0.4); color: #f97316; }
.cv-filter-tabs .filter-tab[data-filter="offline"]:hover { border-color: rgba(168, 85, 247, 0.4); color: #a855f7; }

/* Drag and Drop Node Cards */
.cv-node-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--platform-color, var(--primary-color));
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: grab;
    user-select: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.cv-node-card:active {
    cursor: grabbing;
}

.cv-node-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    background: rgba(255, 255, 255, 0.05);
}

/* Card Themes per Platform */
.cv-node-card[data-platform="google"] { --platform-color: #3b82f6; }
.cv-node-card[data-platform="yahoo"] { --platform-color: #ef4444; }
.cv-node-card[data-platform="ga4"] { --platform-color: #f97316; }
.cv-node-card[data-platform="offline"] { --platform-color: #a855f7; }

/* Dragging visual states */
.cv-node-card.dragging {
    opacity: 0.4;
    transform: scale(0.96);
    border-style: dashed;
}

/* Inside Card Content Styling */
.cv-node-card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.cv-node-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.cv-node-card .platform-badge {
    font-size: 0.62rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--platform-color);
}

.cv-node-card[data-platform="google"] .platform-badge { background: rgba(59, 130, 246, 0.08); border-color: rgba(59, 130, 246, 0.2); }
.cv-node-card[data-platform="yahoo"] .platform-badge { background: rgba(239, 68, 68, 0.08); border-color: rgba(239, 68, 68, 0.2); }
.cv-node-card[data-platform="ga4"] .platform-badge { background: rgba(249, 115, 22, 0.08); border-color: rgba(249, 115, 22, 0.2); }
.cv-node-card[data-platform="offline"] .platform-badge { background: rgba(168, 85, 247, 0.08); border-color: rgba(168, 85, 247, 0.2); }

/* Funnel Stages on Canvas */
.cv-stage-column {
    flex: 1;
    min-width: 250px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.05);
}

.cv-stage-column.drag-over {
    background: rgba(59, 130, 246, 0.04);
    border-color: var(--primary-color);
    box-shadow: 0 0 16px rgba(59, 130, 246, 0.1), inset 0 0 12px rgba(59, 130, 246, 0.05);
}

/* Stage Header */
.cv-stage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.cv-stage-title-input {
    background: transparent;
    border: 1px solid transparent;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    width: 75%;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.cv-stage-title-input:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--border-color);
}

.cv-stage-title-input:focus {
    outline: none;
    background: var(--bg-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Canvas Drop-target zone */
.cv-stage-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 380px;
    border-radius: 8px;
    padding: 4px;
    transition: background-color 0.2s ease;
}

/* Empty drag and drop placeholder */
.cv-stage-empty-placeholder {
    margin: auto 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-align: center;
    padding: 30px 10px;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.01);
}

/* Interactive Details Card on Canvas */
.cv-canvas-node {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--platform-color, var(--primary-color));
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    box-shadow: var(--shadow);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.cv-canvas-node:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.cv-canvas-node .btn-node-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    line-height: 1;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.cv-canvas-node .btn-node-remove:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Canvas Node Editable Fields */
.cv-canvas-node-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
}

.cv-canvas-node-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cv-canvas-node-field label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.cv-canvas-node-field input {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 0.75rem;
    font-family: inherit;
    color: var(--text-primary);
    width: 100%;
}

.cv-canvas-node-field input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Stage Flow Connector Arrow */
.cv-stage-connector {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--border-color);
    font-size: 1.5rem;
    padding: 0 4px;
    user-select: none;
}

/* Offline CV Accordion */
.offline-cv-accordion summary {
    outline: none;
}
.offline-cv-accordion summary .arrow {
    display: inline-block;
    transition: transform 0.2s ease;
    font-size: 0.7rem;
}
.offline-cv-accordion[open] summary .arrow {
    transform: rotate(90deg);
}
.offline-cv-accordion::-webkit-details-marker {
    display: none;
}

/* ==========================================================================
   共通接続・統合接続ダイアログ (siranui-unified-auth-modal) スタイル
   ========================================================================== */

/* 共通接続ステータスバッジ */
.connection-status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    font-size: 0.8rem;
    font-weight: 600;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online {
    background-color: var(--success-color);
    box-shadow: 0 0 8px var(--success-color);
    animation: status-pulse 2s infinite;
}

.status-dot.offline {
    background-color: var(--danger-color);
    box-shadow: 0 0 8px var(--danger-color);
}

@keyframes status-pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.6; }
    100% { transform: scale(1); opacity: 1; }
}

/* ネイティブ dialog モーダル用のオーバーレイとアニメーション設定 */
dialog.modal-overlay-dialog {
    border: none;
    background: transparent;
    padding: 0;
    margin: auto;
    overflow: visible;
}

dialog.modal-overlay-dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

dialog.modal-overlay-dialog[open] {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ダイアログが開いた時の inner box */
dialog.modal-overlay-dialog .modal-box {
    margin: 0;
    max-height: 95vh;
    overflow-y: auto;
    width: 90vw;
    max-width: 550px;
}

/* --- 段階的アカウント連携ウィザードのカスタムCSS --- */

.wizard-step-panel {
    animation: fadeInPanel 0.25s ease-out;
}

.wizard-step-panel.hidden {
    display: none !important;
}

@keyframes fadeInPanel {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.wizard-step-node {
    position: relative;
}

.wizard-step-node.completed .step-circle {
    background: var(--success) !important;
    border-color: var(--success) !important;
    color: white !important;
}

.wizard-step-node.completed {
    color: var(--success) !important;
}

/* ディレクトリツリービューのスタイル */
.tree-view-wrapper {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.tree-view-wrapper::-webkit-scrollbar {
    width: 6px;
}

.tree-view-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
}

.tree-node {
    display: flex;
    flex-direction: column;
    margin-top: 4px;
}

.tree-node-content {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background 0.15s ease;
    cursor: pointer;
}

.tree-node-content:hover {
    background: rgba(255, 255, 255, 0.05);
}

.tree-node-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 0.65rem;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
    cursor: pointer;
}

.tree-node-toggle.expanded {
    transform: rotate(90deg);
}

.tree-node-toggle.leaf {
    visibility: hidden;
    cursor: default;
}

.tree-node-icon {
    font-size: 0.9rem;
    display: inline-block;
    width: 18px;
    text-align: center;
}

.tree-node-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-node-id {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-family: monospace;
}

.tree-node-children {
    display: flex;
    flex-direction: column;
    padding-left: 20px;
    border-left: 1px dashed rgba(255,255,255,0.08);
    margin-left: 14px;
    margin-top: 2px;
}

.tree-node-children.collapsed {
    display: none !important;
}

/* 検索マッチ時のハイライト */
.tree-node-content.search-match {
    background: rgba(59, 130, 246, 0.12) !important;
    border: 1px solid rgba(59, 130, 246, 0.25);
}

.tree-node-content.search-match .tree-node-label {
    color: #60a5fa !important;
    text-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

.tree-node-content.hidden-node,
.tree-node.hidden-node {
    display: none !important;
}

/* クレジットカード模擬決済スタイル */
.card-checkout-form input:focus {
    border-color: var(--success) !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15) !important;
}

/* ドロップダウンオプションの階層インデント */
.global-account-group-select option.indent-option {
    padding-left: 16px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Structure Media Tabs */
.structure-media-tabs-wrapper {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
}

.structure-media-tabs-wrapper::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.structure-media-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0.5rem 1.2rem;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap !important;
    flex-shrink: 0;
}

.structure-media-tab:hover:not(.disabled) {
    background: rgba(59, 130, 246, 0.05);
    color: var(--primary-color);
    border-color: rgba(59, 130, 246, 0.2);
}

.structure-media-tab.active {
    background: rgba(59, 130, 246, 0.12);
    color: var(--text-primary);
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
}

.structure-media-tab.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.structure-media-tab img {
    width: 14px;
    height: 14px;
    object-fit: contain;
}

/* --- Structure Agent: long narrative / comments layout --- */
.structure-results-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    gap: 2rem;
    margin-bottom: 2rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .structure-results-grid {
        grid-template-columns: 1fr;
    }
}

.structure-narrative-content {
    font-size: 0.9rem;
    line-height: 1.65;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    max-height: min(360px, 42vh);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 6px;
}

.structure-alerts-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: min(360px, 42vh);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 6px;
}

.structure-alert-card {
    border-radius: 12px;
    padding: 1.2rem;
    margin-bottom: 0;
    min-width: 0;
}

.structure-alert-title {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.9rem;
    word-break: break-word;
    overflow-wrap: anywhere;
    flex: 1;
    min-width: 0;
}

.structure-alert-description {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 0.5rem;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.structure-tree {
    max-height: 500px;
    overflow-y: auto;
    overflow-x: hidden;
}

.structure-tree .structure-tree-node-title,
.structure-tree .structure-tree-node-meta {
    word-break: break-word;
    overflow-wrap: anywhere;
}

.structure-visualizer-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 2rem;
    align-items: start;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

@media (max-width: 900px) {
    .structure-visualizer-grid {
        grid-template-columns: 1fr;
    }
}

.structure-tools-section {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.structure-consolidation-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0;
}

.structure-consolidation-card {
    min-width: 0;
    overflow: hidden;
}

.structure-consolidation-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
}

.structure-consolidation-lp {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-color);
    word-break: break-all;
    overflow-wrap: anywhere;
    min-width: 0;
    flex: 1;
}

.structure-proposal-reason {
    font-size: 0.8rem;
    line-height: 1.55;
    color: var(--text-primary);
    margin-bottom: 1.2rem;
    background: rgba(255, 255, 255, 0.01);
    border-left: 3px solid var(--primary-color);
    padding: 8px 12px;
    border-radius: 0 6px 6px 0;
    word-break: break-word;
    overflow-wrap: anywhere;
    max-height: 200px;
    overflow-y: auto;
}

.structure-asset-text-cell {
    max-width: 240px;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
}

#modal-consolidation-target-ag,
#modal-consolidation-source-ag {
    word-break: break-word;
    overflow-wrap: anywhere;
}


/* Onboarding Steps Bar Styles */
.onboarding-steps-container {
    width: 100%;
    max-width: 900px;
    margin: 1.5rem auto 0.5rem auto;
    padding: 0 1rem;
    box-sizing: border-box;
}

.onboarding-steps-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(30, 41, 59, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow);
}

.step-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    user-select: none;
}

.step-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.step-label {
    white-space: nowrap;
    transition: all 0.3s ease;
}

/* Step Active State */
.step-item.active {
    color: var(--text-primary);
    font-weight: 700;
}

.step-item.active .step-number {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    color: white;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.step-item.active .step-label {
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Step Completed (Clickable to Go Back) State */
.step-item.completed {
    color: var(--success-color);
    cursor: pointer;
}

.step-item.completed:hover {
    filter: brightness(1.2);
    transform: translateY(-1px);
}

.step-item.completed .step-number {
    border-color: var(--success-color);
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.step-item.completed .step-label {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 4px;
}

/* Step Disabled (Future step) State */
.step-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Step Connector Line */
.step-connector {
    flex: 1;
    height: 2px;
    background: var(--border-color);
    margin: 0 1rem;
    position: relative;
    border-radius: 1px;
}

.step-connector.active {
    background: linear-gradient(to right, var(--success-color), var(--border-color));
}

.step-connector.completed {
    background: var(--success-color);
}

/* Responsive Styles for Steps Bar */
@media (max-width: 640px) {
    .onboarding-steps-bar {
        padding: 0.75rem 1rem;
    }
    .step-label {
        display: none; /* Hide labels on mobile to save space */
    }
    .step-connector {
        margin: 0 0.5rem;
    }
}

/* Push Confirm Modal UI Styles */
.confirm-summary-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    font-family: inherit;
}

.confirm-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
}

.confirm-meta-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.confirm-meta-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.confirm-meta-value {
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--text-primary);
}

.confirm-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: bold;
    border-radius: 4px;
    width: fit-content;
}

.confirm-badge-media {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary-color);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.confirm-badge-mode-replace {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.confirm-badge-mode-add {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.confirm-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.confirm-section-header {
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--primary-color);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    border-left: 3px solid var(--primary-color);
    padding-left: 8px;
}

.confirm-section-content {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.85rem 1rem;
}

.confirm-list {
    margin: 0;
    padding-left: 1.25rem;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.confirm-list li {
    margin-bottom: 4px;
}

.confirm-list li:last-child {
    margin-bottom: 0;
}

.confirm-sub-section {
    margin-bottom: 0.75rem;
}

.confirm-sub-section:last-child {
    margin-bottom: 0;
}

.confirm-sub-title {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: bold;
    display: block;
    margin-bottom: 4px;
}

.confirm-tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.8rem;
    margin-top: 4px;
}

.confirm-tag {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--text-primary);
}

.action-bar {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Accordion toggle button styles */
.accordion-toggle-btn {
    display: block;
    width: 100%;
    max-width: 320px;
    margin: 1.5rem auto 2.5rem auto;
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    outline: none;
}
.accordion-toggle-btn:hover {
    background: var(--border-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.accordion-toggle-btn:active {
    transform: translateY(0);
}

/* Step Setup 2-Column Grid Layout */
.setup-grid {
    display: grid;
    grid-template-columns: 1.4fr 0.6fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .setup-grid {
        grid-template-columns: 1fr;
    }
}

/* Timeline styles for Setup Workflow Panel */
.process-timeline {
    position: relative;
    padding-left: 1.5rem;
    border-left: 2px solid rgba(255, 255, 255, 0.08);
}
.process-timeline-item {
    position: relative;
}
.process-timeline-badge {
    position: absolute;
    left: calc(-1.5rem - 6px);
    top: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #475569;
    border: 2px solid var(--bg-color, #0f172a);
    transition: all 0.3s;
}
.process-timeline-item.active .process-timeline-badge {
    background: var(--primary-color);
    box-shadow: 0 0 8px var(--primary-color);
}
.process-timeline-title {
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--text-primary);
    margin: 0 0 4px 0;
}
.process-timeline-item.active .process-timeline-title {
    color: var(--primary-color);
}
.process-timeline-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
}

/* --- AI Proposal Notification Banner --- */
.opt-proposal-notification-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, 0.25);
    background: rgba(30, 41, 59, 0.45);
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    gap: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.opt-proposal-notification-banner.hidden {
    display: none !important;
}

.banner-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
}

.banner-icon {
    font-size: 1.6rem;
    animation: bannerPulse 2s infinite ease-in-out;
}

@keyframes bannerPulse {
    0% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.15); opacity: 1; filter: drop-shadow(0 0 6px rgba(59,130,246,0.6)); }
    100% { transform: scale(1); opacity: 0.9; }
}

.notification-title {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.notification-desc {
    display: block;
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.banner-right {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: nowrap;
}

.banner-right button {
    margin-bottom: 0 !important;
    padding: 8px 16px;
    font-size: 0.8rem;
    font-weight: bold;
    white-space: nowrap;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

/* Light Theme overrides */
[data-theme="light"] .opt-proposal-notification-banner {
    background: rgba(241, 245, 249, 0.9);
    border: 1px solid rgba(59, 130, 246, 0.3);
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

/* Proposal Detail Modal Content Custom styles */
.proposal-diff-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 0.85rem;
}

.proposal-diff-table th, .proposal-diff-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .proposal-diff-table th, [data-theme="light"] .proposal-diff-table td {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.proposal-diff-table th {
    font-weight: bold;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.15);
}

/* 自動最適化 承認前提案ビュー */
.opt-proposal-view {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.opt-proposal-summary {
    padding: 16px 18px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.2);
}

.opt-proposal-summary--pending {
    border-color: rgba(16, 185, 129, 0.35);
    background: rgba(16, 185, 129, 0.06);
}

.opt-proposal-summary--clear {
    border-color: rgba(148, 163, 184, 0.25);
}

.opt-proposal-summary-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    margin-top: 10px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.opt-proposal-summary-note {
    margin: 10px 0 0;
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.opt-proposal-section-title {
    margin: 0 0 10px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.opt-proposal-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
}

.opt-proposal-badge--action {
    color: #34d399;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.opt-proposal-badge--muted {
    color: #94a3b8;
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.opt-proposal-row--action {
    background: rgba(16, 185, 129, 0.04);
}

.opt-proposal-row--muted {
    opacity: 0.75;
}

.opt-proposal-details {
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.opt-proposal-details summary {
    cursor: pointer;
    padding: 6px 0;
    user-select: none;
}

.opt-proposal-details--log .opt-proposal-raw-log {
    white-space: pre-wrap;
    font-family: monospace;
    font-size: 0.75rem;
    line-height: 1.5;
    color: #94a3b8;
    max-height: 28vh;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.25);
    padding: 12px;
    border-radius: 8px;
    margin-top: 8px;
}

.opt-proposal-error {
    padding: 20px;
    color: #f87171;
    text-align: center;
}

.opt-apply-mode-notice {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(148, 163, 184, 0.08);
    color: var(--text-secondary);
}

.opt-apply-mode-notice--active {
    border-color: rgba(16, 185, 129, 0.35);
    background: rgba(16, 185, 129, 0.08);
    color: #a7f3d0;
}

.opt-apply-mode-notice--inactive {
    border-color: rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.08);
    color: #fcd34d;
}

.opt-proposal-section--focused {
    outline: 2px solid rgba(96, 165, 250, 0.55);
    outline-offset: 4px;
    border-radius: 10px;
    transition: outline-color 0.3s ease;
}

.notify-approval-history-section {
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.notify-approval-history-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.notify-approval-history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.notify-approval-history-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border: 1px dashed var(--border-color);
    border-radius: 10px;
}

.notify-approval-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px 16px;
    align-items: center;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
}

.notify-approval-item__main {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    min-width: 0;
}

.notify-approval-item__icon {
    font-size: 1.35rem;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 2px;
}

.notify-approval-item__body {
    min-width: 0;
}

.notify-approval-item__head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.notify-approval-item__title {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 600;
}

.notify-approval-item__subtitle {
    margin: 0 0 6px;
    font-size: 0.76rem;
    color: var(--text-secondary);
}

.notify-approval-item__summary {
    margin: 0 0 4px;
    font-size: 0.84rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.notify-approval-item__meta {
    margin: 0;
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.notify-approval-item__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
}

.notify-approval-item__no-action {
    font-size: 0.82rem;
    color: var(--text-secondary);
    padding: 0 8px;
}

.notify-approval-settings-link {
    color: var(--primary-color);
    text-decoration: underline;
    font-size: 0.8rem;
}

.notify-approval-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.notify-approval-badge--approved {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.notify-approval-badge--pending {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.notify-approval-badge--muted {
    background: rgba(148, 163, 184, 0.12);
    color: var(--text-secondary);
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.notify-approval-badge--unknown {
    background: rgba(148, 163, 184, 0.12);
    color: var(--text-secondary);
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.notify-approval-action--revoke {
    border-color: rgba(239, 68, 68, 0.35) !important;
    color: #f87171 !important;
}

@media (max-width: 720px) {
    .notify-approval-item {
        grid-template-columns: 1fr;
    }

    .notify-approval-item__actions {
        justify-content: flex-start;
    }
}

/* Non-transparent (opaque) card style for Light/Dark Theme to maximize readability */
.glass {
    background: #0f172a !important; /* Fully opaque dark background */
    border: 1px solid var(--border-color) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

[data-theme="light"] .glass {
    background: #f8fafc !important; /* Fully opaque light background */
}


.glass-inner {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
}
[data-theme="light"] .glass-inner {
    background: rgba(0, 0, 0, 0.02);
}

/* Disabled Navigation Item style */
.nav-item.disabled {
    opacity: 0.45 !important;
    cursor: not-allowed !important;
}
.nav-item.disabled:hover {
    background: transparent !important;
    color: var(--text-primary) !important;
}

/* Uncontracted Warning Banners style */
.uncontracted-warning {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.2rem;
    border: 1px solid;
    font-size: 0.85rem;
    line-height: 1.5;
}
.uncontracted-warning.warning-red {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.25);
    color: #f87171;
}
.uncontracted-warning.warning-purple {
    background: rgba(139, 92, 246, 0.08);
    border-color: rgba(139, 92, 246, 0.25);
    color: #c084fc;
}

/* Setup / notification views use column flex when active */
#notification-settings-view.tab-content:not(.hidden),
#account-group-setup-view.tab-content:not(.hidden),
#cv-group-setup-view.tab-content:not(.hidden) {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* Audience analysis extension layout */
#tab-audience-agent.tab-content:not(.hidden) {
    display: flex;
}

.audience-monitoring-grid,
.audience-expansion-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.6fr);
    gap: 24px;
    align-items: start;
    width: 100%;
}

.audience-monitoring-left,
.audience-expansion-left {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    min-width: 0;
}

.audience-monitoring-right,
.audience-expansion-right {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    min-width: 0;
    align-self: stretch;
}

.audience-ai-summary-card {
    display: flex;
    flex-direction: column;
    min-height: 320px;
    max-height: 760px;
    height: auto;
    box-sizing: border-box;
}

.audience-ai-summary-body,
.audience-summary-text {
    text-align: left;
    align-self: stretch;
    width: 100%;
    white-space: normal;
    overflow-x: hidden;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    line-height: 1.65;
}

.audience-summary-text strong {
    color: var(--primary-color);
    font-weight: 700;
}

.audience-llm-degraded-notice {
    margin-bottom: 0.75rem;
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    background: rgba(255, 193, 7, 0.12);
    border: 1px solid rgba(255, 193, 7, 0.35);
    color: var(--text-primary);
    font-size: 0.8rem;
    line-height: 1.5;
}

.audience-pie-chart-wrap {
    height: 240px;
    position: relative;
    width: 100%;
}

.audience-summary-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-style: italic;
    padding: 0.5rem 0;
    text-align: left;
}

/* Agent tab error overlay – class-based (no inline display corruption) */
.agent-tab-error-slot {
    display: none;
}

.agent-tab-error-mode > :not(.agent-header):not(.agent-tab-error-slot):not(.agent-tab-error-preserve):not([id$="-uncontracted-warning"]) {
    display: none !important;
}

.agent-tab-error-mode > .agent-tab-error-slot {
    display: block;
}

.audience-quota-cache-banner {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.1);
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.5;
}

@media (max-width: 1180px) {
    .audience-monitoring-grid,
    .audience-expansion-grid {
        grid-template-columns: 1fr;
    }

    .audience-ai-summary-card {
        max-height: none;
    }
}

