/* ============================================================
   PORTAL — extends the main site's CSS variables
   ============================================================ */

/* ── Layout ── */
.portal-body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.portal-body--auth {
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
}

.portal-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
  flex: 1;
}

/* ── Portal Nav ── */
.portal-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10,13,18,0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0;
}

.portal-nav__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.portal-nav__brand {
  display: flex;
  flex-direction: column;
  gap: 0;
  text-decoration: none;
  flex-shrink: 0;
}

.portal-nav__name {
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
  color: var(--text);
}

.portal-nav__sub {
  font-size: 0.65rem;
  color: var(--accent);
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.portal-nav__links {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  flex: 1;
}

.portal-nav__links a {
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: color var(--transition);
  text-decoration: none;
}

.portal-nav__links a:hover,
.portal-nav__links a.active {
  color: var(--text);
}

.portal-nav__links a.active {
  color: var(--accent);
}

.portal-nav__user {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
  flex-shrink: 0;
}

.portal-nav__username {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-nav__logout {
  display: inline;
}

/* ── Main ── */
.portal-main {
  flex: 1;
  padding-top: 2.5rem;
}

/* ── Page Header ── */
.portal-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.portal-heading {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 0.25rem;
}

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  transition: border-color var(--transition);
}

.stat-card:hover { border-color: rgba(0,229,192,0.2); }

.stat-card__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card__icon--teal  { background: rgba(0,229,192,0.12); color: var(--accent); }
.stat-card__icon--blue  { background: rgba(0,119,255,0.12); color: #4da3ff; }
.stat-card__icon--amber { background: rgba(255,184,0,0.12);  color: #ffb800; }
.stat-card__icon--red   { background: rgba(255,80,80,0.12);  color: #ff6b6b; }

.stat-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stat-card__value {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--text);
}

.stat-card__label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── Portal Section ── */
.portal-section {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 2rem;
}

.portal-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.portal-section__title {
  font-size: 1rem;
  font-weight: 600;
}

/* ── Data Table ── */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th {
  text-align: left;
  padding: 0.85rem 1.25rem;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--text-muted);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

.row-inactive td { opacity: 0.5; }

.host-name {
  display: block;
  color: var(--text);
  font-weight: 500;
}

.host-hostname {
  display: block;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-top: 0.1rem;
}

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

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

.risk-high {
  color: #ff6b6b;
  font-weight: 600;
}

.actions-cell {
  white-space: nowrap;
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

/* ── Frequency Select ── */
.freq-select {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}

.freq-select:focus { border-color: rgba(0,229,192,0.4); }

/* ── Status Badges ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.status-badge--teal  { color: var(--accent);  background: rgba(0,229,192,0.1); }
.status-badge--blue  { color: #4da3ff;         background: rgba(0,119,255,0.1); }
.status-badge--amber { color: #ffb800;         background: rgba(255,184,0,0.1); }
.status-badge--red   { color: #ff6b6b;         background: rgba(255,80,80,0.1); }
.status-badge--grey  { color: var(--text-faint); background: rgba(255,255,255,0.05); }

/* ── Button extras ── */
.btn--sm  { padding: 0.4rem 1rem; font-size: 0.82rem; }
.btn--xs  { padding: 0.3rem 0.7rem; font-size: 0.75rem; }
.btn--danger {
  background: transparent;
  color: #ff6b6b;
  border: 1px solid rgba(255,107,107,0.3);
}
.btn--danger:hover {
  background: rgba(255,80,80,0.1);
  border-color: #ff6b6b;
}

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--text-muted);
}

.empty-state__icon {
  width: 64px;
  height: 64px;
  background: var(--bg-3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
}

.empty-state a { color: var(--accent); }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  animation: modalIn 0.18s ease;
}

.modal--narrow { max-width: 360px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 1rem; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.25rem;
  transition: color var(--transition);
}

.modal-close:hover { color: var(--text); }

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* ── Auth Page ── */
.auth-wrap {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  text-decoration: none;
}

.auth-brand__name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.auth-brand__sub {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--accent);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.auth-card {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

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

.auth-tab:hover:not(.active) { color: var(--text); background: rgba(255,255,255,0.02); }

.auth-panel {
  padding: 2rem;
}

.auth-feedback {
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  margin-bottom: 1rem;
}

.auth-feedback.is-error {
  background: rgba(255,80,80,0.08);
  border: 1px solid rgba(255,107,107,0.3);
  color: #ff6b6b;
}

.auth-feedback.is-success {
  background: rgba(0,229,192,0.08);
  border: 1px solid rgba(0,229,192,0.3);
  color: var(--accent);
}

.auth-back {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.auth-back a {
  color: var(--text-muted);
  transition: color var(--transition);
}

.auth-back a:hover { color: var(--accent); }

/* ── Reports ── */
.report-meta {
  margin-top: 0.4rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.report-host {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.report-host:last-of-type { border-bottom: none; }

.report-host__title {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.scan-ports-table { font-family: var(--font-mono); }

.back-link {
  display: inline-block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  transition: color var(--transition);
}

.back-link:hover { color: var(--accent); }

.filter-form { display: flex; align-items: center; }

.filter-select {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}

.filter-select:focus { border-color: rgba(0,229,192,0.4); }

/* ── Footer ── */
.portal-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
}

.portal-footer__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-faint);
}

.portal-footer__inner a {
  color: var(--text-muted);
  transition: color var(--transition);
}

.portal-footer__inner a:hover { color: var(--accent); }

/* ── Risk Register ── */
.modal--wide { max-width: 660px; }

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form__group { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.9rem; }
.form__label { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }
.req { color: #ff6b6b; }

.source-badge {
  display: inline-block;
  margin-top: 0.15rem;
  font-size: 0.62rem;
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: rgba(0,229,192,0.08);
  color: var(--accent);
  border: 1px solid rgba(0,229,192,0.2);
}

.overdue-badge {
  display: inline-block;
  margin-left: 0.4rem;
  font-size: 0.62rem;
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: rgba(255,80,80,0.1);
  color: #ff6b6b;
  border: 1px solid rgba(255,107,107,0.3);
}

/* ── Trend chart ── */
.trend-chart-wrap {
  padding: 1.5rem 1.5rem 0.25rem;
}

.trend-chart {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.trend-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.trend-bars {
  display: flex;
  gap: 4px;
  align-items: flex-end;
  height: 64px;
}

.trend-bar {
  width: 14px;
  border-radius: 3px 3px 0 0;
  min-height: 0;
  transition: opacity 0.2s;
}

.trend-bar:hover { opacity: 0.75; }

.trend-bar--open     { background: rgba(0,229,192,0.55); }
.trend-bar--resolved { background: rgba(77,163,255,0.55); }

.trend-label {
  font-size: 0.62rem;
  font-family: var(--font-mono);
  color: var(--text-faint);
  white-space: nowrap;
}

.trend-nums {
  font-size: 0.58rem;
  font-family: var(--font-mono);
  color: var(--text-faint);
}

.trend-legend {
  display: flex;
  gap: 1rem;
  align-items: center;
  font-size: 0.75rem;
}

.trend-legend__item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
}

.trend-legend__item::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.trend-legend__item--open::before     { background: rgba(0,229,192,0.55); }
.trend-legend__item--resolved::before { background: rgba(77,163,255,0.55); }

/* ── Dashboard risk snapshot ── */
.risk-snap-bars { padding: 1.25rem 1.5rem 1.5rem; display: flex; flex-direction: column; gap: 0.75rem; }

.risk-snap-row {
  display: grid;
  grid-template-columns: 60px 1fr 32px;
  align-items: center;
  gap: 0.75rem;
}

.risk-snap-label {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.risk-snap-track {
  height: 6px;
  background: var(--bg-3);
  border-radius: 3px;
  overflow: hidden;
}

.risk-snap-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.risk-snap-fill--critical { background: #ff6b6b; }
.risk-snap-fill--high     { background: #ffb800; }
.risk-snap-fill--medium   { background: #4da3ff; }
.risk-snap-fill--low      { background: var(--text-faint); }

.risk-snap-count {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-align: right;
}

/* ── Link button (inline in empty-state text) ── */
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: inherit;
  padding: 0;
  text-decoration: underline;
}

/* Spin animation (reuse from main) */
.scan-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Responsive ── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px) {
  .form-grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .trend-chart { gap: 0.4rem; }
  .trend-bar { width: 10px; }

  .portal-page-header { align-items: flex-start; }

  .portal-nav__username { display: none; }

  .actions-cell { flex-wrap: wrap; }
}
