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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

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

/* === Navbar === */
.navbar {
    background: #1a1a2e;
    color: #fff;
    padding: 0.8rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-brand a { color: #fff; text-decoration: none; font-weight: bold; font-size: 1.1rem; }
.nav-links a { color: #a0aec0; text-decoration: none; margin-left: 1.5rem; transition: color 0.2s; }
.nav-links a:hover { color: #fff; }

/* === Typography === */
h1 { font-size: 1.5rem; margin-bottom: 1rem; }
h2 { font-size: 1.2rem; margin-bottom: 0.8rem; color: #1a1a2e; }
h3 { font-size: 1rem; margin-bottom: 0.5rem; }

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.2s;
}
.btn-primary { background: #4361ee; color: #fff; }
.btn-primary:hover { background: #3a56d4; }
.btn-secondary { background: #e2e8f0; color: #333; }
.btn-secondary:hover { background: #cbd5e0; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

/* === Badge === */
.badge {
    background: #e2e8f0;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: normal;
}
.score-badge {
    background: #ebf8ff;
    color: #2b6cb0;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.85rem;
}

/* === Status Badges === */
.status-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}
.status-未営業 { background: #e2e8f0; color: #4a5568; }
.status-送信済 { background: #bee3f8; color: #2b6cb0; }
.status-返信あり { background: #c6f6d5; color: #276749; }
.status-商談 { background: #fefcbf; color: #975a16; }
.status-契約 { background: #c6f6d5; color: #22543d; }

/* === Stats Grid === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    text-align: center;
}
.stat-number { font-size: 2rem; font-weight: bold; color: #4361ee; }
.stat-label { color: #718096; font-size: 0.9rem; margin-top: 0.3rem; }

/* === Tables === */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.data-table th, .data-table td {
    padding: 0.7rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}
.data-table th { background: #f7fafc; font-weight: 600; font-size: 0.85rem; color: #4a5568; }
.data-table td { font-size: 0.9rem; }
.data-table a { color: #4361ee; text-decoration: none; }
.data-table a:hover { text-decoration: underline; }

/* === Forms === */
.search-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.search-bar input { flex: 1; padding: 0.5rem 1rem; border: 1px solid #e2e8f0; border-radius: 6px; }

.search-form { background: #fff; padding: 2rem; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); max-width: 600px; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.3rem; font-weight: 500; font-size: 0.9rem; }
.form-group input, .form-group select {
    width: 100%;
    padding: 0.5rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
}

/* === Detail === */
.detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
.detail-card {
    background: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.detail-card dl { display: grid; grid-template-columns: 100px 1fr; gap: 0.3rem; }
.detail-card dt { font-weight: 600; font-size: 0.85rem; color: #718096; }
.detail-card dd { font-size: 0.9rem; margin-bottom: 0.5rem; }

/* === Misc === */
.info-box {
    background: #ebf8ff;
    border-left: 4px solid #4361ee;
    padding: 1rem 1.5rem;
    border-radius: 0 6px 6px 0;
    margin-top: 1.5rem;
}
.info-box h3 { color: #2b6cb0; }
.info-box ul { margin-left: 1.2rem; font-size: 0.9rem; }

.empty-state { color: #a0aec0; text-align: center; padding: 2rem; }
.empty-state a { color: #4361ee; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.5rem; }
.sns-list { list-style: none; display: flex; gap: 1rem; }
.sns-list a { color: #4361ee; }

.mt-2 { margin-top: 1rem; }
.score { font-weight: bold; color: #4361ee; }

/* === CRM === */
.crm-filters { margin-bottom: 1.5rem; }
.status-tabs { display: flex; gap: 0.3rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tab {
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.85rem;
    background: #e2e8f0;
    color: #4a5568;
    transition: background 0.2s;
}
.tab:hover { background: #cbd5e0; }
.tab.active { background: #4361ee; color: #fff; }
.tab-blacklist { background: #fed7d7; color: #9b2c2c; }

.crm-actions { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.crm-actions .search-bar { flex: 1; min-width: 300px; }
.export-buttons { display: flex; gap: 0.5rem; }

.inline-form { display: inline; }
.inline-actions { display: flex; gap: 0.5rem; align-items: center; }
.status-select {
    padding: 0.3rem 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 0.85rem;
}
.memo-cell { max-width: 200px; font-size: 0.8rem; color: #718096; }
.memo-textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
}

.btn-danger { background: #e53e3e; color: #fff; }
.btn-danger:hover { background: #c53030; }
.nav-export { color: #68d391 !important; }
.nav-settings { color: #ecc94b !important; }
.nav-org { color: #b794f4 !important; }
.nav-logout { color: #fc8181 !important; margin-left: 0.5rem; padding-left: 1rem; border-left: 1px solid #4a5568; }

/* === Navbar User Section === */
.nav-user {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-left: auto;
    padding-left: 1.5rem;
}
.user-org {
    background: rgba(255,255,255,0.15);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #e2e8f0;
}
.user-name {
    font-size: 0.85rem;
    color: #a0aec0;
}
.org-switcher select {
    background: rgba(255,255,255,0.1);
    color: #e2e8f0;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
}
.org-switcher select option { background: #1a1a2e; color: #fff; }

/* === Settings === */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.settings-desc { color: #718096; font-size: 0.9rem; margin-bottom: 1.5rem; }
.form-row { display: flex; gap: 1rem; }
.alert { padding: 0.8rem 1.2rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert-success { background: #c6f6d5; color: #276749; }
.alert-error { background: #fed7d7; color: #9b2c2c; }
@media (max-width: 768px) { .settings-grid { grid-template-columns: 1fr; } .form-row { flex-direction: column; } }

/* === Result Badges === */
.badge-success { background: #c6f6d5; color: #276749; }
.badge-warning { background: #fefcbf; color: #975a16; }
.badge-error { background: #fed7d7; color: #9b2c2c; }
.row-success { background: #f0fff4; }
.row-error { background: #fff5f5; }

/* === Email Preview === */
.email-preview {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 1.5rem;
    font-size: 0.9rem;
}
.email-preview pre {
    white-space: pre-wrap;
    font-family: inherit;
    margin-top: 0.5rem;
}
.email-preview hr { border: none; border-top: 1px solid #e2e8f0; margin: 0.8rem 0; }
code { background: #edf2f7; padding: 0.1rem 0.4rem; border-radius: 3px; font-size: 0.85rem; }

/* === Dashboard === */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Pipeline */
.pipeline { display: flex; align-items: center; justify-content: center; gap: 0.3rem; padding: 1rem 0; flex-wrap: wrap; }
.pipeline-stage a { text-decoration: none; color: inherit; text-align: center; }
.pipeline-count {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: #e2e8f0;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; font-weight: bold; color: #4a5568;
    margin: 0 auto 0.3rem;
    transition: background 0.2s;
}
.pipeline-active { background: #4361ee; color: #fff; }
.pipeline-label { font-size: 0.75rem; color: #718096; }
.pipeline-arrow { color: #cbd5e0; font-size: 1.2rem; margin: 0 0.2rem; }
.pipeline-note { text-align: center; font-size: 0.8rem; color: #a0aec0; margin-top: 0.5rem; }
.pipeline-note a { color: #e53e3e; }

/* Progress Bars */
.progress-list { display: flex; flex-direction: column; gap: 0.8rem; }
.progress-item { display: flex; align-items: center; gap: 0.8rem; }
.progress-label { width: 80px; font-size: 0.85rem; color: #4a5568; flex-shrink: 0; }
.progress-bar-wrap { flex: 1; height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; background: #4361ee; border-radius: 4px; min-width: 2px; transition: width 0.3s; }
.bar-green { background: #38a169; }
.progress-value { font-size: 0.8rem; color: #718096; width: 70px; text-align: right; flex-shrink: 0; }

/* Action List */
.action-list { display: flex; flex-direction: column; gap: 0.5rem; }
.action-item {
    display: flex; align-items: center; gap: 1rem;
    padding: 0.8rem 1rem;
    background: #f7fafc;
    border-radius: 6px;
    text-decoration: none; color: inherit;
    transition: background 0.2s;
}
.action-item:hover { background: #edf2f7; }
.action-icon { font-size: 1.5rem; flex-shrink: 0; }
.action-title { font-weight: 600; font-size: 0.9rem; }
.action-desc { font-size: 0.8rem; color: #718096; }

/* Compact Table */
.data-table.compact td, .data-table.compact th { padding: 0.4rem 0.7rem; font-size: 0.85rem; }

@media (max-width: 768px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .pipeline { gap: 0.2rem; }
}

@media (max-width: 768px) {
    .detail-grid { grid-template-columns: 1fr; }
    .crm-actions { flex-direction: column; }
}
