:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --danger: #dc3545;
    --warning: #ffc107;
    --success: #28a745;
    --info: #17a2b8;
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --text: #333333;
    --text-muted: #6c757d;
    --text-secondary: #6c757d;
    --border: #e0e0e0;
    --sev1: #dc3545;
    --sev2: #fd7e14;
    --sev3: #ffc107;
    --sev4: #17a2b8;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.navbar {
    background: linear-gradient(135deg, #1a237e, #283593);
    color: white;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar h1 {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar a { color: white; text-decoration: none; }

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    transition: transform 0.2s;
}

.stat-card:hover { transform: translateY(-2px); }

.stat-card .label {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 32px;
    font-weight: 700;
}

.stat-card.active .value { color: var(--danger); }
.stat-card.resolved .value { color: var(--success); }
.stat-card.mttr .value { color: var(--primary); }
.stat-card.postmortem .value { color: var(--warning); }

.stat-card[onclick] { cursor: pointer; }
.stat-card[onclick]:hover { transform: translateY(-3px); box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
.stat-card.stat-card-selected { outline: 3px solid var(--primary); outline-offset: -3px; transform: translateY(-2px); box-shadow: 0 4px 16px rgba(26,115,232,0.25); }

/* Inline edit select */
.inline-edit-select {
    font-size: 13px;
    padding: 2px 6px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    color: var(--text);
    transition: border-color 0.2s;
}
.inline-edit-select:hover { border-color: var(--primary); }
.inline-edit-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(26,115,232,0.15); }

/* Grid layouts */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.grid-3 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.chart-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
    align-items: stretch;
}

.chart-row .card {
    display: flex;
    flex-direction: column;
}

.chart-row .card-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body { padding: 20px; }

/* Incident Table */
.incident-table {
    width: 100%;
    border-collapse: collapse;
}

.incident-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    letter-spacing: 0.5px;
}

.incident-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.incident-table tr:hover { background: #f8f9fa; }
.incident-table tr:last-child td { border-bottom: none; }

.btn-delete {
    background: none;
    border: 1px solid #dc3545;
    color: #dc3545;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-delete:hover {
    background: #dc3545;
    color: white;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-sev1 { background: #fde8e8; color: var(--sev1); }
.badge-sev2 { background: #fff3e0; color: var(--sev2); }
.badge-sev3 { background: #fff8e1; color: #b8860b; }
.badge-sev4 { background: #e0f7fa; color: var(--sev4); }

.badge-detected { background: #fde8e8; color: #ef4444; }
.badge-mitigating { background: #fff3e0; color: #f59e0b; }
.badge-resolved { background: #e8f5e9; color: #10b981; }

.badge-pending { background: #fff8e1; color: #b8860b; }
.badge-in_progress { background: #e3f2fd; color: var(--primary); }
.badge-completed { background: #e8f5e9; color: var(--success); }

.badge-high { background: #fde8e8; color: var(--danger); }
.badge-medium { background: #fff3e0; color: var(--sev2); }
.badge-low { background: #e0f7fa; color: var(--sev4); }

/* Timeline */
.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    margin-bottom: 16px;
    padding-left: 16px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid white;
    box-shadow: 0 0 0 2px var(--primary);
}

.timeline-item.resolved::before { background: var(--success); box-shadow: 0 0 0 2px var(--success); }
.timeline-item.incident_created::before { background: var(--danger); box-shadow: 0 0 0 2px var(--danger); }

.timeline-time {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.timeline-desc { font-size: 14px; }

/* Roles */
.role-list { list-style: none; }

.role-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.role-item:last-child { border-bottom: none; }

.role-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.role-label {
    font-size: 12px;
    color: var(--text-muted);
}

.role-name { font-weight: 600; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #218838; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c82333; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: #f0f0f0; }

.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active { display: flex; }

.modal {
    background: white;
    border-radius: 16px;
    width: 560px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 { font-size: 18px; }

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body { padding: 24px; }

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,115,232,0.1);
}

textarea.form-control { min-height: 80px; resize: vertical; }
select.form-control { appearance: auto; }

/* Charts placeholder */
.chart-container {
    width: 100%;
    height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Postmortem section */
.postmortem-section {
    background: #fafafa;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.postmortem-section h4 {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.postmortem-section p,
.postmortem-section pre {
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
}

/* Action items */
.action-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.action-item:last-child { border-bottom: none; }

.action-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.action-completed { text-decoration: line-through; color: var(--text-muted); }

/* Responsive */
@media (max-width: 768px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .container { padding: 16px; }
    .chart-row { grid-template-columns: 1fr; }
}

/* Link styling */
a.incident-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

a.incident-link:hover { text-decoration: underline; }

/* Slack commands section */
.slack-cmd {
    font-family: 'SFMono-Regular', monospace;
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.empty-state .icon { font-size: 48px; margin-bottom: 16px; }

/* Product tabs */
.product-tab {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--card-bg);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.product-tab:hover {
    background: #e8f0fe;
    border-color: var(--primary);
}

.product-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: 1px solid var(--primary);
    padding: 8px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

/* Failure level badges */
.badge-partial_outage { background: #fff3cd; color: #856404; }
.badge-site_down { background: #f8d7da; color: #721c24; }

/* Phase badges */
.badge-ph1 { background: #d1ecf1; color: #0c5460; }
.badge-ph2 { background: #fff3cd; color: #856404; }
.badge-ph3 { background: #ffe0cc; color: #8a4500; }
.badge-ph4 { background: #f8d7da; color: #721c24; }

/* Data leak badges */
.badge-dataleak-investigating { background: #fff3cd; color: #856404; }
.badge-dataleak-none { background: #d4edda; color: #155724; }
.badge-dataleak-confirmed { background: #f8d7da; color: #721c24; }

/* AI spinner */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ai-btn { transition: all 0.2s; border: none; cursor: pointer; border-radius: 8px; }
.ai-btn:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.ai-btn:disabled { opacity: 0.6; cursor: wait; transform: none; box-shadow: none; }
