/* ============================================================
   Stratos BEP — Design System Stylesheet
   Light theme: #F8FAFC page, #FFFFFF cards, #1E3A5F sidebar
   ============================================================ */

/* --- CSS Variables --- */
:root {
  --bg-page:           #F8FAFC;
  --bg-card:           #FFFFFF;
  --bg-card-hover:     #F8FAFC;
  --bg-sidebar:        #1E3A5F;
  --bg-nav:            #1E293B;
  --border:            #E2E8F0;
  --border-strong:     #CBD5E1;
  --text-primary:      #1E293B;
  --text-secondary:    #64748B;
  --text-muted:        #94A3B8;
  --accent:            #2563EB;
  --accent-hover:      #1D4ED8;
  --accent-light:      #DBEAFE;
  --clean-text:        #16A34A;
  --clean-bg:          #DCFCE7;
  --clean-border:      #BBF7D0;
  --suspicious-text:   #D97706;
  --suspicious-bg:     #FEF3C7;
  --suspicious-border: #FDE68A;
  --malicious-text:    #DC2626;
  --malicious-bg:      #FEE2E2;
  --malicious-border:  #FECACA;
  --radius:            8px;
  --radius-sm:         6px;
  --shadow-card:       0 1px 3px rgba(0,0,0,0.06);
  --shadow-lg:         0 4px 12px rgba(0,0,0,0.08);
  --sidebar-width:     240px;
  --topnav-height:     56px;
  --font-body:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:         'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

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

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-page);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

img { max-width: 100%; }

code, pre, .text-mono {
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

pre {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* --- Layout: Sidebar + Main --- */
.layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar__logo {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: -0.02em;
}

.sidebar__logo-sub {
  font-size: 0.75rem;
  color: #93C5FD;
  font-weight: 400;
}

.sidebar__nav {
  padding: 12px 0;
  flex: 1;
}

.sidebar__section-title {
  padding: 16px 16px 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: #CBD5E1;
  font-size: 0.875rem;
  font-weight: 400;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s;
}

.sidebar__link:hover {
  background: rgba(255,255,255,0.08);
  color: #E2E8F0;
  text-decoration: none;
}

.sidebar__link--active {
  background: rgba(255,255,255,0.15);
  border-left-color: #60A5FA;
  color: #FFFFFF;
  font-weight: 500;
}

.sidebar__link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}
.sidebar__link--active svg {
  opacity: 1;
}

/* --- Main Area --- */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- Top Nav --- */
.topnav {
  height: var(--topnav-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topnav__title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.topnav__user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
}

.topnav__username {
  color: var(--text-secondary);
  font-weight: 500;
}

.topnav__logout {
  color: var(--text-muted);
  font-size: 0.8125rem;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.topnav__logout:hover {
  color: var(--malicious-text);
  border-color: var(--malicious-border);
  background: var(--malicious-bg);
  text-decoration: none;
}

/* --- Content Area --- */
.content {
  padding: 24px;
  flex: 1;
}

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.card--hover:hover {
  background: var(--bg-card-hover);
}

.card__title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.card__subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

/* --- Stat Cards Grid --- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
  border-left: 4px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-card--clean  { border-left-color: var(--clean-text); }
.stat-card--suspicious { border-left-color: var(--suspicious-text); }
.stat-card--malicious  { border-left-color: var(--malicious-text); }

.stat-card__label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 4px;
}

.stat-card__value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-card__icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* --- Verdict Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge--clean {
  color: var(--clean-text);
  background: var(--clean-bg);
  border: 1px solid var(--clean-border);
}

.badge--suspicious {
  color: var(--suspicious-text);
  background: var(--suspicious-bg);
  border: 1px solid var(--suspicious-border);
}

.badge--malicious {
  color: var(--malicious-text);
  background: var(--malicious-bg);
  border: 1px solid var(--malicious-border);
}

.badge--role {
  color: var(--accent);
  background: var(--accent-light);
  border: 1px solid #BFDBFE;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Auth result badges */
.badge--pass {
  color: #FFFFFF;
  background: var(--clean-text);
  border: 1px solid var(--clean-text);
}
.badge--fail {
  color: #FFFFFF;
  background: var(--malicious-text);
  border: 1px solid var(--malicious-text);
}
.badge--softfail,
.badge--none {
  color: #FFFFFF;
  background: var(--suspicious-text);
  border: 1px solid var(--suspicious-text);
}

/* Severity badges */
.badge--critical {
  color: var(--malicious-text);
  background: var(--malicious-bg);
  border: 1px solid var(--malicious-border);
}
.badge--high {
  color: #C2410C;
  background: #FFF7ED;
  border: 1px solid #FDBA74;
}
.badge--medium {
  color: var(--suspicious-text);
  background: var(--suspicious-bg);
  border: 1px solid var(--suspicious-border);
}
.badge--low {
  color: var(--text-secondary);
  background: #F1F5F9;
  border: 1px solid var(--border);
}

/* --- Score Bar --- */
.score-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  min-width: 60px;
}

.score-bar__fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
  background: var(--clean-text);
}

.score-bar__fill--green   { background: var(--clean-text); }
.score-bar__fill--amber   { background: var(--suspicious-text); }
.score-bar__fill--red     { background: var(--malicious-text); }

.score-display {
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-number {
  font-weight: 600;
  font-size: 0.875rem;
  min-width: 24px;
}

.score-number--large {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
}

/* --- Tables --- */
.table-wrap {
  overflow-x: auto;
}

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

thead th {
  background: var(--bg-page);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--text-primary);
  vertical-align: middle;
}

tbody tr:hover {
  background: var(--bg-card-hover);
}

tbody tr:last-child td {
  border-bottom: none;
}

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

.td-mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.td-muted {
  color: var(--text-muted);
}

/* --- Tab Navigation --- */
.tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
}

.tab-panel--active {
  display: block;
}

/* --- Filter Bar --- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* --- Forms / Inputs --- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="search"],
select,
textarea {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

input::placeholder {
  color: var(--text-muted);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.form-group input {
  width: 100%;
}

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

.btn--primary {
  background: var(--accent);
  color: #FFFFFF;
}
.btn--primary:hover {
  background: var(--accent-hover);
  color: #FFFFFF;
  text-decoration: none;
}

.btn--secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn--secondary:hover {
  background: var(--bg-page);
  color: var(--text-primary);
  text-decoration: none;
}

.btn--success {
  background: var(--clean-text);
  color: #FFFFFF;
}
.btn--success:hover {
  background: #15803D;
  color: #FFFFFF;
  text-decoration: none;
}

.btn--danger {
  background: var(--malicious-text);
  color: #FFFFFF;
}
.btn--danger:hover {
  background: #B91C1C;
  color: #FFFFFF;
  text-decoration: none;
}

.btn--danger-outline {
  background: transparent;
  color: var(--malicious-text);
  border: 1px solid var(--malicious-border);
}
.btn--danger-outline:hover {
  background: var(--malicious-bg);
  text-decoration: none;
}

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

.btn--link {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 8px 12px;
}
.btn--link:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

/* --- Flash Messages --- */
.flash-container {
  padding: 16px 24px 0;
}

.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 8px;
  animation: flashIn 0.25s ease;
  transition: opacity 0.3s;
}

.flash--success {
  background: var(--clean-bg);
  color: var(--clean-text);
  border: 1px solid var(--clean-border);
}

.flash--warning {
  background: var(--suspicious-bg);
  color: var(--suspicious-text);
  border: 1px solid var(--suspicious-border);
}

.flash--error,
.flash--danger {
  background: var(--malicious-bg);
  color: var(--malicious-text);
  border: 1px solid var(--malicious-border);
}

.flash--info {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid #BFDBFE;
}

.flash__dismiss {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  padding: 0 4px;
  line-height: 1;
}
.flash__dismiss:hover {
  opacity: 1;
}

.flash--fade-out {
  opacity: 0;
}

@keyframes flashIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Modal --- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay--active {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  max-width: 420px;
  width: 90%;
}

.modal__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.modal__text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.pagination__links {
  display: flex;
  gap: 6px;
}

.pagination__links a,
.pagination__links span {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-decoration: none;
}

.pagination__links a:hover {
  background: var(--bg-page);
  color: var(--text-primary);
  text-decoration: none;
}

.pagination__links .pagination__current {
  background: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent);
}

/* --- Login Page --- */
.login-page {
  min-height: 100vh;
  background: var(--bg-page);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

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

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo__icon {
  display: inline-block;
  margin-bottom: 8px;
}

.login-logo__title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.login-logo__sub {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.login-heading {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 24px;
  text-align: center;
}

.login-error {
  background: var(--malicious-bg);
  color: var(--malicious-text);
  border: 1px solid var(--malicious-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.8125rem;
  margin-bottom: 16px;
}

.login-btn {
  width: 100%;
  padding: 10px 16px;
  font-size: 0.9375rem;
}

/* --- Detail Page Header --- */
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 20px;
}

.detail-header__left {
  flex: 1;
  min-width: 0;
}

.detail-header__subject {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 8px 0;
  word-break: break-word;
}

.detail-header__meta {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.detail-header__right {
  text-align: right;
  flex-shrink: 0;
}

.detail-header__status {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* --- Description List --- */
.dl-headers dt {
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dl-headers dd {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-primary);
  padding: 4px 0;
  word-break: break-all;
}

/* --- Inline Stats --- */
.inline-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.inline-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.inline-stat__value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.inline-stat__label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --- Action Buttons Group --- */
.action-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.action-form {
  display: inline;
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* --- Pulsing Dot --- */
.pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--malicious-text);
  animation: pulse 1.5s ease-in-out infinite;
  margin-left: 6px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.5; transform: scale(1.3); }
}

/* --- Utility --- */
.mb-0  { margin-bottom: 0; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.gap-8  { gap: 8px; }
.gap-16 { gap: 16px; }
.flex   { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-sm { font-size: 0.8125rem; }
.font-mono { font-family: var(--font-mono); }
.font-semibold { font-weight: 600; }
.w-full { width: 100%; }

/* --- Responsive --- */
@media (max-width: 1024px) {
  .sidebar {
    width: 200px;
    min-width: 200px;
  }
  .main {
    margin-left: 200px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: var(--sidebar-width);
  }
  .sidebar--open {
    transform: translateX(0);
  }
  .main {
    margin-left: 0;
  }
  .content {
    padding: 16px;
  }
  .stat-grid {
    grid-template-columns: 1fr;
  }
  .detail-header {
    flex-direction: column;
  }
  .detail-header__right {
    text-align: left;
  }
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
}
