:root {
  --app-sidebar-width: 240px;
  --app-sidebar-bg: #0f172a;
  --app-sidebar-fg: #cbd5e1;
  --app-sidebar-muted: #64748b;
  --app-sidebar-active: #1e293b;
  --app-accent: #3b82f6;
  --app-body-bg: #f1f5f9;
}

[data-bs-theme="dark"] {
  --app-sidebar-bg: #0b1120;
  --app-sidebar-active: #1e293b;
  --app-body-bg: #111827;
}

body {
  background: var(--app-body-bg);
  font-size: 0.925rem;
}

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
  --bs-offcanvas-width: var(--app-sidebar-width);
  background: var(--app-sidebar-bg);
  color: var(--app-sidebar-fg);
}
@media (min-width: 992px) {
  .app-sidebar {
    width: var(--app-sidebar-width);
    flex: 0 0 var(--app-sidebar-width);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }
}
@media (max-width: 991.98px) {
  .app-sidebar.offcanvas-lg { background: var(--app-sidebar-bg); color: var(--app-sidebar-fg); }
  .app-sidebar .offcanvas-header { color: #fff; border-color: rgba(255, 255, 255, 0.08) !important; }
  .app-sidebar .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }
}
.app-sidebar .border-top { border-color: rgba(255, 255, 255, 0.08) !important; }
.app-sidebar .text-body-secondary { color: var(--app-sidebar-muted) !important; }

.app-sidebar .brand {
  align-items: center;
  gap: 0.6rem;
  padding: 1.1rem 1.25rem;
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.app-sidebar .brand i { color: var(--app-accent); font-size: 1.3rem; }

.app-sidebar .nav-link {
  color: var(--app-sidebar-fg);
  border-radius: 0.4rem;
  padding: 0.5rem 0.75rem;
  display: flex;
  gap: 0.6rem;
  align-items: center;
}
.app-sidebar .nav-link:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.app-sidebar .nav-link.active { background: var(--app-sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--app-accent); }
.app-sidebar .nav-section {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--app-sidebar-muted);
  padding: 1rem 0.75rem 0.35rem;
}

.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  background: var(--bs-body-bg);
  border-bottom: 1px solid var(--bs-border-color);
  position: sticky;
  top: 0;
  z-index: 1020;
}
.app-content { padding: 1.5rem; }
@media (max-width: 575.98px) {
  .app-topbar { padding: 0.6rem 1rem; }
  .app-content { padding: 1rem; }
}

/* ---------- Komponen ---------- */
.card { border-color: var(--bs-border-color-translucent); }
.card-header { background: transparent; font-weight: 600; }

.stat-card .card-body { position: relative; }
.stat-card .stat-icon { position: absolute; top: 1rem; right: 1rem; font-size: 1.5rem; opacity: 0.85; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.stat-card .stat-label { color: var(--bs-secondary-color); font-size: 0.82rem; }

.info-tile {
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  padding: 0.75rem 0.9rem;
  height: 100%;
  background: var(--bs-tertiary-bg);
}
.info-tile .info-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--bs-secondary-color); }
.info-tile .info-value { font-weight: 600; margin: 0.15rem 0; }

.section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bs-secondary-color);
  margin-bottom: 0.6rem;
}

.result-hero { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }

.kv-table th { width: 220px; white-space: nowrap; font-weight: 600; color: var(--bs-secondary-color); }
@media (max-width: 575.98px) { .kv-table th { width: auto; white-space: normal; } }
.col-type { width: 90px; }
.td-url { max-width: 280px; }
.td-server { max-width: 200px; }
.min-w-0 { min-width: 0; }
code { word-break: break-word; }

.detail-tabs { border-bottom: 0; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
.detail-tabs .nav-link { white-space: nowrap; }
.detail-tabs .nav-link.active { background: var(--bs-body-bg); }
.card-tabbed { border-top-left-radius: 0; }

/* Tombol dengan indikator loading */
.check-form .btn-spinner,
.check-form .btn-label-loading { display: none; }
.check-form.is-loading .btn-spinner,
.check-form.is-loading .btn-label-loading { display: inline-block; }
.check-form.is-loading .btn-label { display: none; }

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(1px);
}
.loading-overlay[hidden] { display: none; }

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card { width: 100%; max-width: 420px; }
.login-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  margin: 0 auto 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--app-sidebar-bg);
  color: var(--app-accent);
  font-size: 1.6rem;
}

/* ---------- Jadwal scan & tabel domain ---------- */
.schedule-select { min-width: 150px; }
.td-modules { max-width: 220px; }

/* ---------- Tabel domain (dashboard) ---------- */
.domain-table { font-size: 0.85rem; }
.domain-table thead th {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bs-secondary-color);
  white-space: nowrap;
  background: var(--bs-tertiary-bg);
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}
.domain-table thead th .bi { opacity: 0.7; margin-right: 0.15rem; }
:is(.domain-table, .sched-table) .th-wrap { display: flex; align-items: center; gap: 0.15rem; }
:is(.domain-table, .sched-table) .th-sort { color: inherit; text-decoration: none; }
:is(.domain-table, .sched-table) .th-sort:hover, :is(.domain-table, .sched-table) .th-sort.active { color: var(--bs-emphasis-color); }
:is(.domain-table, .sched-table) .th-sort-icon { opacity: 0.35; margin-left: 0.15rem; }
:is(.domain-table, .sched-table) .th-sort.active .th-sort-icon { opacity: 1; color: var(--bs-primary); }
:is(.domain-table, .sched-table) .th-filter { border: 0; background: none; padding: 0.1rem 0.25rem; border-radius: 0.25rem; color: inherit; line-height: 1; }
:is(.domain-table, .sched-table) .th-filter:hover, :is(.domain-table, .sched-table) .th-filter[aria-expanded="true"] { background: var(--bs-secondary-bg); }
:is(.domain-table, .sched-table) .th-filter.active { color: var(--bs-primary); }
:is(.domain-table, .sched-table) .th-filter.active .bi { opacity: 1; }
.th-menu { max-height: 60vh; overflow-y: auto; font-size: 0.82rem; text-transform: none; letter-spacing: normal; font-weight: 400; min-width: 14rem; }
.th-menu .dropdown-header { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; }
.th-menu .th-count { color: var(--bs-secondary-color); font-variant-numeric: tabular-nums; }
.th-menu .active .th-count { color: inherit; }
.filter-chip { font-weight: 500; }
.domain-table td { vertical-align: top; padding: 0.75rem 0.45rem; }
.domain-table th { padding-left: 0.45rem; padding-right: 0.45rem; }
.domain-table td:first-child, .domain-table th:first-child { padding-left: 0.9rem; }
.domain-table td:last-child, .domain-table th:last-child { padding-right: 0.9rem; }
.domain-table .cell-main { line-height: 1.35; }
.domain-table .cell-sub { font-size: 0.76rem; color: var(--bs-secondary-color); line-height: 1.35; margin-top: 0.2rem; }
.domain-table .cell-empty { font-size: 0.78rem; color: var(--bs-tertiary-color); }
.domain-table .badge { font-weight: 600; }

:is(.domain-table, .sched-table) .th-check, .domain-table .cell-check { padding-right: 0; }
.domain-table .cell-check .form-check-input { margin-top: 0.2rem; }
.domain-table .cell-domain .cell-main a { font-size: 0.92rem; }
.domain-table .cell-actions { white-space: nowrap; }
.domain-table .cell-sub { overflow-wrap: anywhere; }

/* Layar lebar: tabel lebar-tetap, kolom berbagi lebar yang tersedia (tidak pernah scroll ke kanan). */
@media (min-width: 1200px) {
  .domain-table { table-layout: fixed; width: 100%; }
  .domain-table td { overflow: hidden; }
  .domain-table thead th { white-space: normal; overflow-wrap: normal; word-break: normal; letter-spacing: 0.02em; font-size: 0.68rem; }
  .domain-table .col-check { width: 2.4rem; }
  .domain-table .col-actions { width: 7.6rem; }
  .domain-table .col-domain { width: 16%; }
  .domain-table .col-php { width: 11%; }
  .domain-table .col-server { width: 11%; }
  .domain-table .col-dns { width: 9%; }
  .domain-table .col-http { width: 14%; }
  .domain-table .col-tech { width: 13%; }
  .domain-table .col-integrity { width: 11%; }
  .domain-table .col-vuln { width: 11%; }
  :is(.domain-table, .sched-table) .th-wrap { flex-wrap: nowrap; align-items: flex-start; }
  :is(.domain-table, .sched-table) .th-sort { min-width: 0; }
  :is(.domain-table, .sched-table) .th-sort > .bi:first-child { display: none; }  /* ikon modul: hemat ruang di header */
  :is(.domain-table, .sched-table) .th-filter { flex: none; margin-top: -0.05rem; }
}
/* 1200–1399px: sembunyikan kolom pelengkap agar kolom utama tetap lega (lengkapnya ada di halaman detail). */
@media (min-width: 1200px) and (max-width: 1399.98px) {
  .domain-table .col-dns, .domain-table .col-tech { display: none; }
}

/* Layar sempit: setiap baris menjadi kartu; header menjadi deretan chip urut/filter. */
@media (max-width: 1199.98px) {
  .domain-table, .domain-table thead, .domain-table tbody { display: block; width: 100%; }
  .domain-table thead tr { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0.6rem 0.9rem; background: var(--bs-tertiary-bg); border-bottom: 1px solid var(--bs-border-color); }
  .domain-table thead th { display: block; padding: 0 !important; border: 0; background: none; }
  .domain-table thead th.col-actions { display: none; }
  .domain-table thead th.col-check { display: flex; align-items: center; margin-right: 0.2rem; }
  .domain-table thead th:not(.col-check):not(.col-actions) .th-wrap {
    border: 1px solid var(--bs-border-color); border-radius: 999px; padding: 0.15rem 0.35rem 0.15rem 0.6rem; background: var(--bs-body-bg);
  }
  .domain-table tbody tr {
    position: relative;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.6rem 1rem;
    padding: 0.85rem 0.9rem 0.9rem 2.6rem;
    border-bottom: 1px solid var(--bs-border-color);
  }
  .domain-table tbody td { display: block; padding: 0 !important; border: 0; min-width: 0; }
  .domain-table tbody td[colspan] { grid-column: 1 / -1; }
  .domain-table td.cell-check { position: absolute; top: 0.85rem; left: 0.9rem; }
  .domain-table td.cell-domain { grid-column: 1 / -1; padding-right: 7.5rem !important; }
  .domain-table td.cell-actions { position: absolute; top: 0.75rem; right: 0.9rem; }
  .domain-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.15rem;
    font-size: 0.66rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--bs-tertiary-color);
  }
}
@media (max-width: 575.98px) {
  .domain-table tbody tr { grid-template-columns: 1fr 1fr; }
  .domain-table td.cell-domain { padding-right: 0 !important; }
  .domain-table td.cell-actions { position: static; grid-column: 1 / -1; text-align: left !important; }
}

.status-dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  margin-right: 0.35rem;
  vertical-align: 0.05rem;
}
.status-dot.dot-up { background: var(--bs-success); box-shadow: 0 0 0 3px rgba(var(--bs-success-rgb), 0.18); }
.status-dot.dot-down { background: var(--bs-danger); box-shadow: 0 0 0 3px rgba(var(--bs-danger-rgb), 0.18); }
.status-dot.dot-unknown { background: var(--bs-secondary); }

.tech-chips { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.tech-chip {
  display: inline-block;
  max-width: 100%;
  padding: 0.1rem 0.45rem;
  font-size: 0.74rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 999px;
  background: var(--bs-tertiary-bg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tech-chip.tech-more { color: var(--bs-secondary-color); }


.cve-desc { min-width: 260px; max-width: 520px; }

.cf-records { max-height: 70vh; overflow-y: auto; }
.cf-records thead th { position: sticky; top: 0; background: var(--bs-body-bg); z-index: 1; }

/* Pencarian realtime: tandai daftar yang sedang dimuat ulang */
.live-region { transition: opacity 0.15s; }
.live-region.is-refreshing, .badge.is-refreshing { opacity: 0.5; pointer-events: none; }

/* ---------- Detail: tab "Semua detail" ---------- */
.all-heading { display: none; }
.tab-content.show-all > .tab-pane:not(#tab-overview) { display: block; opacity: 1; }
.tab-content.show-all .all-heading {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--bs-border-color);
  scroll-margin-top: 5rem;
}
.tab-content.show-all > .tab-pane[id]:not(#tab-overview):not(#tab-all) { margin-top: 2.25rem; scroll-margin-top: 5rem; }
.tab-content.show-all tr.d-none[class*="extra-cve-"] { display: table-row !important; }
.tab-content.show-all [data-reveal] { display: none; }
.all-toc { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.all-toc-link {
  padding: 0.2rem 0.65rem;
  font-size: 0.8rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 999px;
  text-decoration: none;
  color: var(--bs-body-color);
  background: var(--bs-tertiary-bg);
}
.all-toc-link:hover { border-color: var(--bs-primary); color: var(--bs-primary); }
@media print {
  .app-sidebar, .app-topbar, .detail-tabs, .all-toc, .btn, form { display: none !important; }
  .tab-content > .tab-pane:not(#tab-overview) { display: block !important; opacity: 1 !important; }
  .all-heading { display: flex !important; }
}

/* Tabel target terjadwal: judul kolom dengan urut & filter */
.sched-table thead th { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--bs-secondary-color); white-space: nowrap; background: var(--bs-tertiary-bg); }
.sched-table thead th .bi { opacity: 0.7; }
