/* ===== ADMIN & PORTAL SHARED STYLES ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #07070d;
    --bg-surface: #0d0d15;
    --bg-card: #12121e;
    --bg-card-hover: #181828;
    --border: #1e1e32;
    --border-light: #2a2a44;
    --text: #e2e2ec;
    --text-muted: #8888a4;
    --text-dim: #5c5c78;
    --accent: #3b82f6;
    --accent-hover: #5b9aff;
    --accent-glow: rgba(59, 130, 246, 0.15);
    --accent-subtle: rgba(59, 130, 246, 0.08);
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --radius: 8px;
    --radius-lg: 12px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --sidebar-w: 240px;
}

html { height: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; display: block; }

h1, h2, h3, h4 { font-weight: 600; color: #fff; line-height: 1.3; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }

/* ===== LOGIN PAGE ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-box {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
}

.login-logo { height: 28px; margin: 0 auto 32px; }
.login-box h1 { text-align: center; margin-bottom: 8px; font-size: 1.25rem; }
.login-box .login-sub { text-align: center; color: var(--text-muted); margin-bottom: 28px; font-size: 0.875rem; }

.login-error {
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius);
    color: #f87171;
    font-size: 0.85rem;
    margin-bottom: 20px;
}

.login-success {
    padding: 12px 16px;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: var(--radius);
    color: var(--success);
    font-size: 0.85rem;
    margin-bottom: 20px;
}

/* ===== LAYOUT ===== */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
}

.sidebar-logo {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.sidebar-logo img { height: 24px; }
.sidebar-logo span { display: block; font-size: 0.7rem; color: var(--text-dim); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.08em; }

.sidebar-nav { flex: 1; padding: 16px 12px; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all .15s;
    margin-bottom: 2px;
}
.sidebar-nav a:hover { color: var(--text); background: var(--bg-card); }
.sidebar-nav a.active { color: #fff; background: var(--accent-subtle); }
.sidebar-nav .nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.sidebar-nav a.active .nav-icon { opacity: 1; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
}

.page-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.page-header h1 { margin: 0; }
.page-header-actions { display: flex; gap: 8px; }

.page-body { padding: 24px 32px; }

/* ===== PORTAL LAYOUT ===== */
.portal-layout { min-height: 100vh; }

.portal-header {
    padding: 16px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 24px;
    background: var(--bg-surface);
}

.portal-header img { height: 24px; }
.portal-header-company { font-weight: 600; color: var(--text); margin-left: auto; }
.portal-header-user { color: var(--text-muted); font-size: 0.85rem; }

.portal-body { max-width: 960px; margin: 0 auto; padding: 32px; }

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: #fff; }

/* ===== TABLES ===== */
.table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 24px;
}

.table-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.table-header h3 { margin: 0; }

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

thead th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    vertical-align: top;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-card-hover); }

.td-truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.badge-critical { background: rgba(239,68,68,0.15); color: #f87171; }
.badge-high { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-medium { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-low { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-info { background: rgba(136,136,164,0.15); color: #a8a8c0; }

.badge-lead { background: rgba(136,136,164,0.15); color: #a8a8c0; }
.badge-active { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-completed { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-archived { background: rgba(136,136,164,0.1); color: #6a6a84; }

.badge-scoping { background: rgba(136,136,164,0.15); color: #a8a8c0; }
.badge-in_progress { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-review { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-delivered { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-closed { background: rgba(136,136,164,0.1); color: #6a6a84; }

.badge-open { background: rgba(239,68,68,0.15); color: #f87171; }
.badge-remediated { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-accepted { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-false_positive { background: rgba(136,136,164,0.1); color: #6a6a84; }

.badge-note { background: rgba(136,136,164,0.15); color: #a8a8c0; }
.badge-call { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-email { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-meeting { background: rgba(245,158,11,0.15); color: #fbbf24; }

.tracking-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}
.tracking-dot.opened { background: var(--success); }
.tracking-dot.pending { background: var(--text-dim); }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.8125rem;
    padding: 8px 16px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }

.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--border-light); }
.btn-secondary:hover { border-color: var(--text-muted); color: #fff; }

.btn-danger { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }

.btn-sm { padding: 5px 10px; font-size: 0.75rem; }
.btn-lg { padding: 12px 24px; font-size: 0.9rem; }

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

/* ===== FORMS ===== */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    font-family: var(--font);
    font-size: 0.875rem;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color .2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group textarea { resize: vertical; min-height: 100px; }
.form-group select { appearance: none; cursor: pointer; }

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

.form-actions { display: flex; gap: 8px; margin-top: 24px; }

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h3 { margin: 0; }

.card-body { padding: 20px; }

/* ===== DETAIL VIEW ===== */
.detail-grid {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 12px 16px;
    font-size: 0.875rem;
}

.detail-label { color: var(--text-muted); font-weight: 500; }
.detail-value { color: var(--text); }
.detail-value pre { white-space: pre-wrap; font-family: var(--font); font-size: 0.875rem; color: var(--text); }

/* ===== TIMELINE ===== */
.timeline { padding: 16px 0; }

.timeline-item {
    display: flex;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }

.timeline-meta {
    flex-shrink: 0;
    width: 120px;
    font-size: 0.75rem;
    color: var(--text-dim);
}

.timeline-content { flex: 1; font-size: 0.875rem; }
.timeline-content p { white-space: pre-wrap; }

/* ===== FINDINGS LIST ===== */
.finding-item {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.finding-item:last-child { border-bottom: none; }
.finding-item:hover { background: var(--bg-card-hover); }

.finding-title { font-weight: 500; color: #fff; }
.finding-desc { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ===== REPORTS LIST ===== */
.report-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}
.report-item:last-child { border-bottom: none; }
.report-item:hover { background: var(--bg-card-hover); }
.report-icon { color: var(--accent); flex-shrink: 0; }
.report-info { flex: 1; }
.report-title { font-weight: 500; color: #fff; font-size: 0.875rem; }
.report-meta { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }

/* ===== MODAL ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.modal-overlay.open { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 { margin: 0; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.25rem; padding: 4px; }

.modal-body { padding: 24px; }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-dim);
    font-size: 0.9rem;
}

/* ===== ALERTS ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 20px;
}
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); color: var(--success); }
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #f87171; }
.alert-info { background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.3); color: #60a5fa; }

/* ===== PORTAL ASSESSMENT CARDS ===== */
.assessment-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    transition: border-color .15s;
}
.assessment-card:hover { border-color: var(--border-light); }
.assessment-card h3 { margin-bottom: 4px; }
.assessment-card-meta { font-size: 0.85rem; color: var(--text-muted); }

/* ===== UTILITIES ===== */
.mt-0 { margin-top: 0; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-sm { font-size: 0.8125rem; }
.text-right { text-align: right; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.hidden { display: none !important; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .page-header, .page-body { padding: 16px; }
    .form-row { flex-direction: column; gap: 0; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: 1fr; }
    .portal-body { padding: 16px; }
}
