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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.5;
}

.container { max-width: 1100px; margin: 0 auto; padding: 20px; }

/* App Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}
.main-content {
    flex: 1;
    padding: 24px;
    margin-left: 220px;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 220px;
    height: 100vh;
    background: #1a1a2e;
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 50;
}
.sidebar-brand {
    font-size: 1.15rem;
    font-weight: 700;
    padding: 20px 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 12px 0;
    flex: 1;
}
.sidebar-link {
    display: block;
    padding: 10px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.95rem;
    transition: background 0.15s, color 0.15s;
}
.sidebar-link:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}
.sidebar-link.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-weight: 600;
}
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-email {
    display: block;
    font-size: 0.8rem;
    opacity: 0.7;
    margin-bottom: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-logout {
    width: 100%;
    padding: 6px 0;
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}
.sidebar-logout:hover { background: rgba(255,255,255,0.1); }

/* Auth */
.auth-card {
    max-width: 380px;
    margin: 80px auto;
    background: #fff;
    padding: 32px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.auth-card h2 { margin-bottom: 20px; text-align: center; }
.auth-card input {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.95rem;
}
.auth-card button {
    width: 100%;
    padding: 10px;
    background: #1a1a2e;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}
.auth-card button:hover { background: #16213e; }
.auth-toggle { text-align: center; margin-top: 12px; font-size: 0.9rem; }
.auth-toggle a { color: #1a1a2e; font-weight: 600; }
.error { color: #e74c3c; text-align: center; margin-top: 8px; font-size: 0.9rem; }

/* Buttons */
.btn {
    padding: 8px 16px;
    background: #1a1a2e;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}
.btn:hover { background: #16213e; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 4px 12px; font-size: 0.85rem; }
.btn-danger { background: #e74c3c; }
.btn-danger:hover { background: #c0392b; }

/* Stats */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.stat-card {
    background: #fff;
    padding: 16px;
    border-radius: 6px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.stat-icon {
    width: 28px;
    height: 28px;
    margin-bottom: 6px;
    color: #999;
}
.stat-icon-urgent { color: #e74c3c; }
.stat-icon-breach { color: #27ae60; }
.stat-icon-ai { color: #1a1a2e; }
.stat-value { font-size: 1.75rem; font-weight: 700; }
.stat-label { font-size: 0.85rem; color: #777; margin-top: 4px; }
.stat-urgent .stat-value { color: #e74c3c; }
.stat-breach .stat-value { color: #27ae60; }
.stat-ai .stat-value { color: #1a1a2e; }

/* Tabs */
.tab-panel { display: block; }
.placeholder-text {
    text-align: center;
    color: #999;
    padding: 80px 20px;
    font-size: 1.1rem;
}

/* Controls */
.controls-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.controls-row input, .controls-row select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}
.controls-row input { flex: 1; min-width: 200px; }

/* Table */
.table-container {
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; }
th { background: #fafafa; text-align: left; padding: 10px 14px; font-size: 0.85rem; color: #555; border-bottom: 2px solid #eee; }
td { padding: 10px 14px; border-bottom: 1px solid #f0f0f0; font-size: 0.9rem; }
tr { cursor: pointer; }
tr:hover { background: #fafafa; }

/* Priority badges */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-critical { background: #4a0010; color: #ff4d6d; }
.badge-urgent { background: #fce4e4; color: #e74c3c; }
.badge-high { background: #fef0e4; color: #e67e22; }
.badge-medium { background: #fef5e4; color: #f39c12; }
.badge-low { background: #e4fce8; color: #27ae60; }
.badge-none { background: #eee; color: #999; }
.badge-breach { background: #fce4e4; color: #c0392b; }
.badge-ai { background: #e4e8fc; color: #2c3e8c; }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 16px;
}
.pagination button {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}
.pagination button.active { background: #1a1a2e; color: #fff; border-color: #1a1a2e; }
.pagination button:hover:not(.active) { background: #f5f5f5; }

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal-content {
    background: #fff;
    padding: 28px;
    border-radius: 8px;
    max-width: 650px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}
.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 1.5rem;
    cursor: pointer;
    color: #777;
}
.modal-close:hover { color: #333; }
.modal-meta { margin: 6px 0; font-size: 0.9rem; }
.modal-reasoning { margin: 10px 0; color: #555; font-size: 0.9rem; font-style: italic; }
.modal-body { margin-top: 16px; white-space: pre-wrap; font-size: 0.9rem; line-height: 1.6; }

/* Modal actions */
.modal-actions { margin: 12px 0 8px; }

/* Thread View */
.thread-view { max-width: 800px; }
.thread-header { margin-bottom: 20px; }
.thread-subject { font-size: 1.5rem; font-weight: 700; margin-bottom: 12px; line-height: 1.3; color: #1a1a2e; }
.thread-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.thread-section-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 28px 0 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #eee;
}
.thread-section-header {
    font-size: 1rem;
    font-weight: 700;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
    padding: 0;
    border: none;
}
.thread-list-placeholder { color: #aaa; font-style: italic; list-style: none; padding-left: 0; }
.thread-body-row { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
.thread-body { white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: 0.9rem; color: #333; margin: 0; padding: 0.75rem; background: #f9f9f9; border: 1px solid #e5e7eb; border-radius: 6px; width: 100%; box-sizing: border-box; max-height: 400px; overflow-y: auto; }
.thread-card {
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    padding: 20px;
    margin-bottom: 16px;
}
.thread-card-title { font-size: 0.95rem; font-weight: 700; color: #333; margin-bottom: 14px; }
.thread-detail-row {
    display: flex;
    gap: 16px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
}
.thread-detail-row:last-child { border-bottom: none; padding-bottom: 0; }
.thread-detail-label { width: 70px; color: #777; font-weight: 600; flex-shrink: 0; }
.thread-detail-value { color: #333; }
.thread-list { padding-left: 20px; }
.thread-list li { padding: 5px 0; font-size: 0.9rem; color: #555; line-height: 1.5; }
.badge-processed { background: #e4fce8; color: #27ae60; }
.badge-unprocessed { background: #fef5e4; color: #f39c12; }

/* Responsive */
@media (max-width: 700px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .main-content { margin-left: 0; }
    .sidebar { display: none; }
}
