:root {
  --nav-100: #f1f3f8;
  --nav-200: #e4e9f5;
  --page-1100: #1b273c;
  --page-900: #485161;
  --page-700: #707682;
  --page-600: #8e939b;
  --page-500: #a4a8ae;
  --page-400: #bcbfc3;
  --page-300: #d2d4d6;
  --page-200: #e9eaeb;
  --white: #ffffff;
  --blue: #1d6bfc;
  --blue-600: #357bfc;
  --purple-900: #5e1a64;
  --purple-700: #9f2caa;
  --purple-500: #ca59d4;
  --sidebar-w: 260px;
  --border-card: #ebecee;
  --text-strong: #0c121d;
  --text-subtle: #344565;
  --chart-bar-text: #607497;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Roboto", -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--page-900);
  background: var(--white);
  font-size: 14px;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.icon { width: 16px; height: 16px; display: block; flex-shrink: 0; }

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

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--nav-100);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
}

.sidebar-logo {
  padding: 24px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.logo-mark {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--page-1100);
}
.logo-mark span { color: var(--blue); }

.logo-text {
  font-size: 14px;
  line-height: 16px;
  color: var(--page-1100);
  letter-spacing: 0.08px;
}

.btn {
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--page-1100);
  border-radius: 4px;
}

.btn-outline {
  border: 1px solid var(--page-1100);
  padding: 6px 12px 6px 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
}
.btn-outline:hover { background: var(--white); }

.btn-block { width: 100%; justify-content: center; }

.btn-sm { height: 32px; padding: 6px 12px; font-size: 14px; }

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 16px;
}

.menu-label {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px 0 24px;
  font-size: 12px;
  color: var(--page-700);
}
.menu-label i {
  flex: 1;
  height: 1px;
  background: var(--page-300);
  font-style: normal;
}

.menu-item, .menu-item--group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 24px;
  color: var(--page-900);
  font-size: 14px;
}
.menu-item:hover, .menu-item--group:hover { background: rgba(0,0,0,0.03); }

.menu-item span, .menu-item--group span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-item--group { cursor: pointer; }
.menu-item--group .chevron { transition: transform .15s; }
.menu-item--group.open .chevron { transform: rotate(0deg); }

.menu-subitem {
  display: flex;
  align-items: center;
  padding: 8px 12px 8px 48px;
  color: var(--page-900);
  font-size: 14px;
}
.menu-subitem:hover { background: rgba(0,0,0,0.03); }
.menu-subitem.active { background: var(--nav-200); color: var(--page-1100); }

.chevron-right { color: var(--page-900); margin-left: auto; }

.sidebar-tagline {
  padding: 0 24px 32px;
  font-size: 12px;
  line-height: 16px;
  color: var(--page-500);
}

/* ==================== TOPBAR ==================== */
.topbar {
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 16px;
}

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

.quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 12px 0 8px;
  border-radius: 4px;
  background: var(--white);
  color: var(--page-900);
  font-size: 14px;
  font-weight: 500;
}
.quick-btn:hover { background: var(--page-200); }

.quick-btn--active {
  background: var(--page-900);
  color: var(--white);
}
.quick-btn--active:hover { background: var(--page-900); }

.badge {
  background: var(--blue);
  color: var(--white);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  padding: 0 4px;
  height: 16px;
  line-height: 16px;
  border-radius: 2px;
}

.topbar-shadow {
  height: 4px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.05), transparent);
}

/* ==================== PAGE HEADER ==================== */
.page-header {
  padding: 24px 32px 8px;
}

.page-header-top {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 24px;
}

.icon-btn {
  background: none;
  border: none;
  position: relative;
  display: flex;
  align-items: center;
  color: var(--page-900);
  padding: 0;
}
.icon-btn--text { gap: 4px; }

.icon-btn .dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #d00300;
}

.breadcrumb { padding: 8px 0; }
.breadcrumb h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 500;
  line-height: 24px;
  color: var(--page-1100);
}

.breadcrumb--with-parent { padding: 4px 0; }
.breadcrumb-parent {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--page-700);
  margin-bottom: 4px;
}
.breadcrumb-parent a:hover { text-decoration: underline; }
.breadcrumb-parent .icon { color: var(--page-400); }

.breadcrumb-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-primary {
  background: var(--blue);
  color: var(--white);
  border: none;
  height: 32px;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 2px;
}
.btn-primary:hover { background: #1854c3; }

/* ==================== TABS ==================== */
.tabs-row { padding: 0 32px 16px; }
.tabs {
  display: flex;
  gap: 24px;
  border-bottom: 1px solid var(--page-200);
}
.tab {
  background: none;
  border: none;
  padding: 0 0 6px;
  min-width: 56px;
  font-size: 14px;
  font-weight: 500;
  color: var(--page-700);
  position: relative;
}
.tab--active {
  color: var(--page-1100);
  box-shadow: inset 0 -2px 0 var(--page-1100);
}

/* ==================== FILTERS ==================== */
.filters-row { padding: 0 32px 16px; }
.filters {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.select {
  height: 32px;
  border: 1px solid var(--page-400);
  border-radius: 2px;
  background: var(--white);
  color: var(--page-700);
  font-size: 14px;
  padding: 0 8px;
}
.filters .select:nth-of-type(1) { width: 200px; }
.filters .select:nth-of-type(2) { width: 143px; }
.filters .page-btn { flex-shrink: 0; }

/* ==================== CONTENT BLOCKS ==================== */
.content-block { padding: 0 32px 24px; }

.card {
  border: 1px solid var(--page-300);
  background: var(--white);
}

.card-title {
  padding: 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--page-1100);
  border-bottom: 1px solid var(--page-300);
}
.card-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--page-300);
}
.link { color: var(--blue); font-size: 14px; font-weight: 500; }
.link:hover { text-decoration: underline; }

/* recent detections */
.detections { padding: 20px; display: flex; flex-direction: column; }
.detection-row {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 12px 0;
  border-bottom: 1px solid var(--page-200);
}
.detection-row:last-child { border-bottom: none; padding-bottom: 0; }
.detection-row:first-child { padding-top: 0; }

.detection-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--page-200);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.detection-icon svg { width: 44px; height: 44px; }

.detection-body { flex: 1; min-width: 0; }
.detection-body p {
  margin: 0 0 4px;
  font-size: 14px;
  color: var(--page-900);
  line-height: 20px;
}
.detection-meta {
  font-size: 12px;
  color: var(--page-700);
}

.detection-action {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
}
.detection-action--pending {
  color: var(--page-500);
  font-size: 14px;
  font-weight: 500;
}
.spin { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== REPORTS: STAT CARDS ==================== */
.stats-row {
  display: flex;
  gap: 24px;
}
.stat-card {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 40px;
  border: 1px solid var(--page-200);
  padding: 20px 40px 20px 20px;
}
.stat-icon { flex-shrink: 0; width: 72px; height: 72px; }
.stat-icon svg { width: 100%; height: 100%; }

.stat-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  white-space: nowrap;
}
.stat-number {
  font-size: 20px;
  font-weight: 500;
  line-height: 24px;
  color: var(--page-1100);
}
.stat-caption {
  font-size: 14px;
  color: var(--page-900);
}

.stat-divider {
  align-self: stretch;
  width: 1px;
  background: var(--page-200);
}

.stat-breakdown {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  flex: 1;
  min-width: 0;
}
.stat-breakdown-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--page-900);
  white-space: nowrap;
}
.stat-breakdown-row strong { font-weight: 400; color: var(--page-1100); }

/* ==================== REPORTS: TOOLBAR ==================== */
.reports-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.reports-toolbar-left { display: flex; align-items: center; gap: 24px; }
.view-by { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--page-700); white-space: nowrap; }
.view-by .select { width: 180px; }
.page-size-select {
  border: 1px solid var(--page-400);
  border-radius: 2px;
  background: var(--white);
  color: var(--page-900);
  font-size: 13px;
  padding: 2px 4px;
  margin: 0 2px;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 280px;
  border-bottom: 1px solid var(--page-400);
  padding: 6px 0;
  color: var(--page-700);
}
.search-box input {
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  flex: 1;
  min-width: 0;
  color: var(--page-900);
}
.search-box input::placeholder { color: var(--page-700); }

/* ==================== REPORTS: TABLE ==================== */
.table-card { padding: 0; }
.table-scroll { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th {
  text-align: left;
  padding: 10px 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--page-1100);
  border-bottom: 1px solid var(--page-300);
  white-space: nowrap;
  cursor: default;
  user-select: none;
}
.data-table th[data-sort] { cursor: pointer; }
.data-table th[data-sort]:hover { background: var(--page-200); }

.sort-icon {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 4px;
  vertical-align: -1px;
  position: relative;
}
.sort-icon::before, .sort-icon::after {
  content: "";
  position: absolute;
  left: 3px;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
}
.sort-icon::before { top: 0; border-bottom: 4px solid var(--page-400); }
.sort-icon::after { bottom: 0; border-top: 4px solid var(--page-400); }
.th--asc .sort-icon::before { border-bottom-color: var(--page-1100); }
.th--desc .sort-icon::after { border-top-color: var(--page-1100); }

.data-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--page-200);
  color: var(--page-900);
  white-space: nowrap;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(28, 39, 60, 0.02); }

.status-blocked { color: #d00300; }
.status-plain { color: var(--page-900); }

.threat-cell { display: inline-flex; align-items: center; gap: 6px; }
.threat-cell--none { color: var(--page-500); }
.threat-cell--alert { color: var(--page-900); }
.threat-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.threat-dot--red { background: #d00300; }
.threat-dot--grey { background: var(--page-400); }

.user-cell { display: inline-flex; align-items: center; gap: 8px; }
.user-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--white);
  flex-shrink: 0;
}
.user-avatar--guest {
  background: var(--page-200);
  color: var(--page-700);
}
.user-avatar--guest .icon { width: 12px; height: 12px; }


.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  font-size: 13px;
  color: var(--page-700);
}
.pagination-controls { display: flex; align-items: center; gap: 8px; }
.page-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--page-300);
  background: var(--white);
  border-radius: 2px;
  color: var(--page-900);
}
.page-btn:hover { background: var(--page-200); }
.page-btn:disabled { color: var(--page-400); cursor: not-allowed; }

/* ==================== DASHBOARD v2 ==================== */
.dashboard-row { display: flex; gap: 24px; align-items: stretch; }

.chart-card-v2, .stat-card-v2 {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  border-color: var(--border-card);
}
.chart-card-v2 .card-title, .stat-card-v2 .card-title {
  border-color: var(--border-card);
}
.chart-card-v2-body { padding: 20px; flex: 1; display: flex; align-items: center; }

/* donut chart */
.donut-chart-wrap { display: flex; align-items: center; gap: 40px; width: 100%; }
.donut {
  width: 184px;
  height: 184px;
  flex-shrink: 0;
  position: relative;
  cursor: pointer;
}
.donut svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.donut-segment { transition: opacity 0.15s ease, filter 0.15s ease; }
.donut-chart-wrap.is-focused .donut-segment { opacity: 0.35; filter: saturate(0.6); }
.donut-chart-wrap.is-focused .donut-segment.seg--active { opacity: 1; filter: none; }
.donut-total {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 500;
  line-height: 36px;
  color: var(--text-strong);
  pointer-events: none;
}
.donut-legend { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.donut-legend-row { display: flex; align-items: center; gap: 8px; cursor: pointer; border-radius: 3px; transition: opacity 0.15s ease, background-color 0.15s ease; }
.donut-legend-row i { width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0; transition: filter 0.15s ease; }
.donut-legend-row .label { flex: 1; min-width: 0; font-size: 14px; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend-row .value { font-size: 14px; color: var(--text-subtle); flex-shrink: 0; }
.donut-chart-wrap.is-focused .donut-legend-row { opacity: 0.5; }
.donut-chart-wrap.is-focused .donut-legend-row.seg--active { opacity: 1; background: var(--page-200); }

/* blocked media breakdown */
.breakdown-list { display: flex; flex-direction: column; gap: 2px; width: 100%; }
.breakdown-row { display: flex; align-items: center; gap: 16px; padding: 6px 8px; margin: 0 -8px; cursor: pointer; border-radius: 3px; transition: opacity 0.15s ease, background-color 0.15s ease; }
.breakdown-divider { height: 1px; background: var(--border-card); margin: 6px 0; }
.breakdown-label { width: 200px; flex-shrink: 0; font-size: 14px; color: var(--text-subtle); }
.breakdown-track-wrap { flex: 1; min-width: 0; display: flex; align-items: center; gap: 16px; }
.breakdown-fill { height: 8px; transition: filter 0.15s ease; }
.breakdown-value { font-size: 13px; color: var(--text-strong); flex-shrink: 0; }
.breakdown-list.is-focused .breakdown-row { opacity: 0.4; }
.breakdown-list.is-focused .breakdown-row--active { opacity: 1; background: var(--page-200); }
.breakdown-list.is-focused .breakdown-row--active .breakdown-fill { filter: brightness(1.15) saturate(1.15); }

/* stat cards with mini bar chart */
.stat-card-v2-body { padding: 20px; flex: 1; display: flex; flex-direction: column; justify-content: space-between; gap: 20px; }
.stat-number-block { display: flex; flex-direction: column; gap: 4px; }
.stat-number-label { font-size: 14px; color: var(--text-subtle); }
.stat-number-value { font-size: 20px; font-weight: 500; line-height: 24px; color: var(--text-strong); }

.legend-tall { display: flex; flex-direction: column; gap: 12px; }
.legend-tall-row { display: flex; align-items: center; gap: 8px; cursor: pointer; border-radius: 3px; transition: opacity 0.15s ease, background-color 0.15s ease; }
.legend-tall-row i { width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0; transition: filter 0.15s ease; }
.legend-tall-row .label { flex: 1; min-width: 0; font-size: 14px; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-tall-row .value { font-size: 14px; color: var(--text-subtle); flex-shrink: 0; }
.stat-card-v2-body.is-focused .legend-tall-row { opacity: 0.5; }
.stat-card-v2-body.is-focused .legend-tall-row.seg--active { opacity: 1; background: var(--page-200); }
.stat-card-v2-body.is-focused .legend-tall-row.seg--active i { filter: brightness(1.15) saturate(1.15); }

.mini-bars { display: flex; align-items: flex-end; gap: 2px; height: 144px; }
.mini-bar-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; cursor: pointer; }
.mini-bar-value { font-size: 12px; color: var(--chart-bar-text); padding: 0 4px 2px; }
.mini-bar-fill { width: 100%; border-radius: 4px 4px 0 0; transition: opacity 0.15s ease, filter 0.15s ease; }
.stat-card-v2-body.is-focused .mini-bar-fill { opacity: 0.35; filter: saturate(0.6); }
.stat-card-v2-body.is-focused .mini-bar-col.seg--active .mini-bar-fill { opacity: 1; filter: brightness(1.15) saturate(1.15); }

/* ==================== DETAIL PAGES (shared) ==================== */
.button-group { display: flex; gap: 8px; }

.banner-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 20px;
  border: 1px solid var(--border-card);
}
.banner-icon { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.banner-card--blocked .banner-icon, .banner-card--blocked .banner-title { color: #d40031; }
.banner-card--allowed .banner-icon, .banner-card--allowed .banner-title { color: #1aab8a; }
.banner-title { font-size: 14px; font-weight: 500; margin: 0 0 4px; }
.banner-desc { font-size: 13px; color: var(--page-900); margin: 0; line-height: 20px; }

.summary-card { display: flex; align-items: center; border: 1px solid var(--border-card); padding: 20px; gap: 20px; }
.summary-main { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; white-space: nowrap; }
.summary-number { font-size: 20px; font-weight: 500; line-height: 24px; color: var(--text-strong); }
.summary-caption { font-size: 14px; color: var(--text-subtle); }
.summary-divider { width: 1px; align-self: stretch; background: var(--border-card); flex-shrink: 0; }
.summary-breakdown { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.summary-breakdown-row { display: flex; justify-content: space-between; font-size: 14px; color: var(--text-subtle); gap: 16px; white-space: nowrap; }
.summary-breakdown-row strong { color: var(--text-strong); font-weight: 500; }

.mini-stats-row { display: flex; gap: 24px; }
.mini-stat-card { flex: 1; min-width: 0; border: 1px solid var(--border-card); padding: 20px; display: flex; flex-direction: column; gap: 4px; }
.mini-stat-value { font-size: 20px; font-weight: 500; line-height: 24px; color: var(--text-strong); }
.mini-stat-label { font-size: 14px; color: var(--text-subtle); }

.collapsible-section { border: 1px solid var(--page-300); }
.collapsible-header { display: flex; align-items: center; justify-content: space-between; padding: 20px; cursor: pointer; }
.collapsible-title { font-size: 14px; font-weight: 500; color: var(--page-1100); }
.collapsible-header-right { display: flex; align-items: center; gap: 16px; }
.collapsible-body { padding: 0 20px 20px; }
.collapsible-section.collapsed .collapsible-body { display: none; }
.collapsible-toggle { transition: transform 0.15s; color: var(--page-700); }
.collapsible-section.collapsed .collapsible-toggle { transform: rotate(180deg); }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 60px; min-width: 0; }
.info-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.info-row { display: flex; gap: 20px; font-size: 14px; min-width: 0; }
.info-label { width: 140px; flex-shrink: 0; color: var(--text-subtle); }
.info-value { color: var(--text-strong); flex: 1; min-width: 0; overflow-wrap: break-word; }

.pill-toggle { display: flex; border: 1px solid var(--page-300); border-radius: 2px; overflow: hidden; flex-shrink: 0; }
.pill-toggle button { padding: 6px 12px; font-size: 13px; border: none; background: var(--white); color: var(--page-700); }
.pill-toggle button.active { background: var(--page-1100); color: var(--white); }

.detail-icon-cell { display: inline-flex; align-items: center; gap: 8px; }
.detail-icon-cell .icon { color: var(--page-600); }

.action-menu-btn { background: none; border: none; color: var(--page-700); padding: 4px; display: inline-flex; }

.category-cell { color: var(--page-900); font-size: 14px; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1100px) {
  .stats-row, .dashboard-row, .mini-stats-row { flex-direction: column; }
  .stat-breakdown-row { white-space: normal; }
}

@media (max-width: 900px) {
  .sidebar { display: none; }
  .topbar-links { flex-wrap: wrap; }
  .reports-toolbar { flex-direction: column; align-items: stretch; }
}
