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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    min-height: 100vh;
}

.hidden { display: none !important; }

.top-nav {
    background: #1a1a2e;
    color: #fff;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    height: 56px;
    gap: 32px;
}

.nav-logo { height: 28px; width: auto; flex-shrink: 0; }
.nav-brand { font-weight: 700; font-size: 18px; color: #4fc3f7; }

.nav-links { display: flex; gap: 8px; flex: 1; min-width: 0; }

.nav-link {
    color: #ccc;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    transition: background 0.15s, color 0.15s;
}

.nav-link:hover { background: rgba(255,255,255,0.1); color: #fff; }

.nav-right { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }

.nav-user { font-size: 14px; color: #aaa; }

.container { max-width: 1400px; margin: 0 auto; padding: 24px; }

.btn-sm {
    background: transparent;
    color: #ccc;
    border: 1px solid #555;
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.btn-sm:hover { color: #fff; border-color: #888; }

/* ---- Cards & Panels ---- */

.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 24px;
    margin-bottom: 20px;
}

.card h2 { font-size: 18px; margin-bottom: 16px; color: #1a1a2e; }

/* ---- Buttons ---- */

.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s, opacity 0.15s;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: #1976d2; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1565c0; }

.btn-success { background: #2e7d32; color: #fff; }
.btn-success:hover:not(:disabled) { background: #1b5e20; }

.btn-danger { background: #d32f2f; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b71c1c; }

.btn-secondary { background: #6c757d; color: #fff; }
.btn-secondary:hover:not(:disabled) { background: #5a6268; }

/* ---- Forms ---- */

.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.15s;
}

.form-control:focus { outline: none; border-color: #1976d2; box-shadow: 0 0 0 3px rgba(25,118,210,0.1); }

select.form-control { appearance: auto; }

textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

/* ---- Table ---- */

.table-wrapper { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: #f8f9fa;
    padding: 12px 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 2px solid #e0e0e0;
    white-space: nowrap;
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    vertical-align: middle;
}

tbody tr:hover { background: #f5f8ff; }

tbody tr.empty-row td { text-align: center; color: #999; padding: 40px; }

.case-link {
    color: inherit;
    text-decoration: none;
    display: block;
    font-weight: 600;
}
.case-link:hover { text-decoration: underline; }
.case-row, .recent-case-row { cursor: pointer; }

/* ---- Severity Badges ---- */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-critical { background: #ffebee; color: #c62828; }
.badge-high { background: #fff3e0; color: #e65100; }
.badge-medium { background: #fff8e1; color: #f9a825; }
.badge-low { background: #e8f5e9; color: #2e7d32; }

.badge-local { background: #e3f2fd; color: #1565c0; }
.badge-warning { background: #fff3e0; color: #e65100; }
.badge-elastic { background: #fce4ec; color: #c62828; }

.badge-open { background: #e8f5e9; color: #2e7d32; }
.badge-in-progress { background: #fff3e0; color: #e65100; }
.badge-closed { background: #eceff1; color: #546e7a; }

/* ---- Status indicator ---- */

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

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

.status-dot.open { background: #4caf50; }
.status-dot.in-progress { background: #ff9800; }
.status-dot.closed { background: #9e9e9e; }

/* ---- Filters ---- */

.filter-bar {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.filter-bar .form-group { margin-bottom: 0; min-width: 160px; flex: 1; max-width: 240px; }

.search-group { flex: 2; max-width: 400px; }

/* ---- Pagination ---- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.pagination button {
    padding: 8px 14px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
}

.pagination button:hover:not(:disabled) { background: #f0f0f0; }
.pagination button:disabled { opacity: 0.4; cursor: default; }
.pagination button.active { background: #1976d2; color: #fff; border-color: #1976d2; }
.pagination span { font-size: 13px; color: #666; }

/* ---- Detail View ---- */

/* ---- Jira-style Case Detail ---- */

.case-detail-jira { padding: 0; overflow: hidden; }

.jira-title-section {
    padding: 20px 24px 16px;
    border-bottom: 1px solid #eee;
}

.jira-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.jira-key {
    font-size: 14px;
    font-weight: 600;
    color: #1976d2;
}

.jira-source-badge { font-size: 11px !important; padding: 1px 8px !important; }

.jira-title-input {
    display: block;
    width: 100%;
    font-size: 20px;
    font-weight: 600;
    color: #1a1a2e;
    border: none;
    padding: 4px 0;
    outline: none;
    background: transparent;
    font-family: inherit;
    line-height: 1.3;
}

.jira-title-input:focus { border-bottom: 2px solid #1976d2; margin-bottom: -2px; }

.jira-title-input::placeholder { color: #bbb; }

.jira-body {
    display: flex;
    gap: 0;
}

.jira-main {
    flex: 1;
    min-width: 0;
    padding: 24px;
    border-right: 1px solid #eee;
}

.jira-section {
    margin-bottom: 32px;
}

.jira-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: #5e6c84;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

/* Remove border on last section */
.jira-section:last-child { margin-bottom: 0; }

.jira-sidebar {
    width: 260px;
    flex-shrink: 0;
    padding: 20px 20px 24px;
    background: #fafbfc;
}

.sidebar-field {
    margin-bottom: 16px;
}

.sidebar-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #5e6c84;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.sidebar-value {
    font-size: 14px;
    color: #333;
    line-height: 1.4;
}

.sidebar-field .form-control {
    font-size: 13px;
    padding: 6px 8px;
}

.sidebar-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 20px 0;
}

.detail-section { margin-bottom: 32px; }
.detail-section h3 { font-size: 16px; margin-bottom: 12px; color: #333; border-bottom: 1px solid #eee; padding-bottom: 8px; }

/* ---- Login ---- */

.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}

.login-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.1);
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
}

.login-card h1 { font-size: 24px; margin-bottom: 8px; text-align: center; }
.login-card p { color: #888; text-align: center; margin-bottom: 32px; font-size: 14px; }

/* ---- Dashboard ---- */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.kpi-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 24px;
    text-align: center;
}

.kpi-value { font-size: 36px; font-weight: 700; color: #1a1a2e; }
.kpi-label { font-size: 13px; color: #888; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.05em; }

.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 32px;
}

.chart-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 24px;
}

.chart-card h3 { font-size: 15px; margin-bottom: 16px; color: #555; }

.chart-row {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    gap: 12px;
}

.chart-row .chart-label { min-width: 80px; font-size: 13px; color: #555; }
.chart-row .chart-value { min-width: 40px; font-weight: 600; font-size: 14px; text-align: right; }

.chart-bar {
    flex: 1;
    height: 24px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
}

.chart-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

/* ---- Comments ---- */

.comment-item {
    padding: 16px;
    margin-bottom: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 3px solid #1976d2;
}

.comment-meta { font-size: 12px; color: #888; margin-bottom: 6px; }
.comment-text { font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.comment-edit-textarea { font-size: 14px; line-height: 1.5; }

.comment-edit-wrap { text-align: right; margin-top: 4px; }

.comment-edit-btn {
    background: transparent;
    color: #1976d2;
    border: none;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.comment-edit-btn:hover { background: #e3f2fd; }

/* ---- Activity ---- */

.activity-item {
    padding: 12px 16px;
    border-left: 2px solid #e0e0e0;
    margin-left: 8px;
    padding-left: 24px;
    position: relative;
    margin-bottom: 4px;
}

.activity-item::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 16px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #1976d2;
}

.activity-meta { font-size: 12px; color: #888; }
.activity-action { font-size: 14px; margin-top: 2px; }
.field-change { margin: 4px 0; line-height: 1.5; }
.field-change.multiline { margin: 8px 0; }
.diff-block { margin: 6px 0 6px 12px; padding: 8px; background: var(--bg-secondary, #f5f5f5); border-radius: 4px; border: 1px solid var(--border, #ddd); }
.diff-old { padding: 4px 8px; background: #fff0f0; border-left: 3px solid #d32f2f; white-space: pre-wrap; font-size: 13px; }
.diff-new { padding: 4px 8px; background: #f0fff0; border-left: 3px solid #2e7d32; white-space: pre-wrap; font-size: 13px; }
.diff-arrow { text-align: center; font-size: 18px; color: #666; padding: 2px 0; }

/* ---- Toast ---- */

.toast-container {
    position: fixed;
    top: 72px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

.toast-success { background: #2e7d32; }
.toast-error { background: #d32f2f; }
.toast-info { background: #1976d2; }
.toast-warning { background: #e65100; }

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

/* ---- Spinner ---- */

.spinner {
    text-align: center;
    padding: 40px;
    color: #888;
}

.spinner::after {
    content: '';
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid #e0e0e0;
    border-top-color: #1976d2;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ---- Tags ---- */

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    background: #e8eaf6;
    color: #283593;
    margin: 2px;
}

/* ---- Empty state ---- */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state h3 { font-size: 18px; margin-bottom: 8px; color: #666; }

/* ---- Responsive ---- */

/* ---- Tenant Switcher ---- */

.nav-tenant { margin: 0 16px; }

.tenant-select {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.25);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    min-width: 140px;
}

.tenant-select option { background: #1a1a2e; color: #fff; }

/* ---- Modal ---- */

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal {
    background: #fff;
    border-radius: 12px;
    padding: 32px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal h2 { font-size: 20px; margin-bottom: 20px; }

/* ---- Profile / MFA ---- */

:root { --muted: #888; }

.nav-profile-link { color: #aaa; font-size: 13px; }
.nav-profile-link:hover { color: #fff; }

#mfa-qr-code svg { width: 180px; height: 180px; display: inline-block; }
#mfa-qr-code { text-align: center; margin-bottom: 8px; }
#mfa-secret-display {
    font-size: 12px;
    word-break: break-all;
    user-select: all;
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
}

@media (max-width: 768px) {
    .chart-grid { grid-template-columns: 1fr; }
    .filter-bar .form-group { min-width: 120px; }
    .form-row { flex-direction: column; gap: 0; }
    .nav-links { gap: 4px; }
    .nav-link { padding: 6px 10px; font-size: 13px; }
    .detail-meta { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .container { padding: 12px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .nav-inner { gap: 12px; }
    .nav-brand { font-size: 14px; }
}
