:root {
  --cdm-navy: #15243b;
  --cdm-navy-soft: #1e3050;
  --cdm-accent: #2f80ed;
  --cdm-bg: #f4f6fa;
}

body {
  background: var(--cdm-bg);
  color: #1d2733;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Nav ---------- */
.cdm-nav {
  background: var(--cdm-navy);
  padding-top: .65rem;
  padding-bottom: .65rem;
  box-shadow: 0 1px 0 rgba(0,0,0,.08);
}
.cdm-nav .navbar-brand { display: flex; align-items: baseline; }
.cdm-logo {
  color: #fff;
  font-weight: 700;
  letter-spacing: .12em;
  font-size: 1.15rem;
}
.cdm-tagline { color: rgba(255,255,255,.55); font-size: .8rem; }
.cdm-nav .navbar-brand { margin-right: 1.5rem; }
.cdm-nav .navbar-nav { gap: .4rem; }
.cdm-nav .nav-link { color: rgba(255,255,255,.75); border-radius: .4rem; padding: .4rem .8rem; }
.cdm-nav .nav-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.cdm-nav .nav-link.active { color: #fff; background: rgba(255,255,255,.14); }
.cdm-nav .navbar-toggler { border-color: rgba(255,255,255,.3); }
.cdm-nav .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255,255,255,0.8%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* ---------- Cards / tables ---------- */
.card {
  border: 1px solid #e3e8f0;
  border-radius: .6rem;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid #eef1f6;
  font-weight: 600;
}
.table > :not(caption) > * > * { padding: .7rem .75rem; }
.table thead th {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #6b7a90;
  border-bottom-width: 1px;
  white-space: nowrap;
}
.table thead th a { color: inherit; text-decoration: none; }
.table thead th a:hover { color: var(--cdm-accent); }
.domain-name { font-weight: 600; color: #15243b; text-decoration: none; }
.domain-name:hover { color: var(--cdm-accent); }
.domain-url {
  display: block;
  font-size: .78rem;
  color: #8a97a8;
  text-decoration: none;
  margin-top: .1rem;
}
.domain-url i { font-size: .65rem; opacity: .7; }
.domain-url:hover { color: var(--cdm-accent); text-decoration: underline; }

/* ---------- Stats ---------- */
.stat-card { background: #fff; border: 1px solid #e3e8f0; border-radius: .6rem; padding: .9rem 1rem; height: 100%; }
.stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: #6b7a90; }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; color: #15243b; }
.stat-card.is-warning .stat-value { color: #b54708; }
.stat-card.is-danger .stat-value { color: #b42318; }

/* ---------- Filter sidebar ---------- */
.facet-panel {
  background: #fff;
  border: 1px solid #e3e8f0;
  border-radius: .6rem;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}
.facet-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .75rem 1rem;
  border-bottom: 1px solid #eef1f6;
  font-weight: 600;
  font-size: .9rem;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
}
.facet { padding: .75rem 1rem; border-bottom: 1px solid #f1f4f9; }
.facet:last-of-type { border-bottom: none; }
.facet-title {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #6b7a90;
  font-weight: 700;
  margin-bottom: .45rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.facet-chip-count {
  background: var(--cdm-accent);
  color: #fff;
  border-radius: 999px;
  font-size: .65rem;
  padding: 0 .35rem;
  line-height: 1.4;
  letter-spacing: 0;
}
.facet-scroll { max-height: 216px; overflow-y: auto; margin-right: -.25rem; padding-right: .25rem; }
.facet-option {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .2rem 0;
  font-size: .87rem;
  cursor: pointer;
  color: #2b3a4d;
}
.facet-option:hover { color: var(--cdm-accent); }
.facet-option .form-check-input { margin: 0; flex: 0 0 auto; cursor: pointer; }
.facet-label { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facet-count { flex: 0 0 auto; font-size: .75rem; color: #98a4b5; font-variant-numeric: tabular-nums; }
.facet-option.is-empty { opacity: .45; }
.facet-empty { font-size: .8rem; color: #98a4b5; }

/* ---------- Active filter chips ---------- */
.chip-row { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: #fff;
  border: 1px solid #d8e0ec;
  border-radius: 999px;
  padding: .15rem .6rem;
  font-size: .78rem;
  color: #2b3a4d;
  text-decoration: none;
}
.chip:hover { border-color: var(--cdm-accent); color: var(--cdm-accent); }
.chip i { font-size: .7rem; opacity: .6; }
.chip-clear { background: transparent; border-style: dashed; color: #6b7a90; }

/* ---------- Search + results ---------- */
.search-bar .input-group-text { color: #8a97a8; }
.search-bar .form-control { box-shadow: none; }
.search-bar .form-control:focus { border-color: #d8e0ec; }
#cdm-results { transition: opacity .12s ease; }
#cdm-results.is-loading { opacity: .45; pointer-events: none; }

/* ---------- Auth screens ---------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: linear-gradient(160deg, var(--cdm-navy) 0%, var(--cdm-navy-soft) 55%, #26406b 100%);
}
.auth-page > main { width: 100%; }
.auth-page .cdm-footer { color: rgba(255,255,255,.4); }
.auth-card { width: 100%; max-width: 420px; margin: 2rem auto; }
.auth-card .card { border: none; box-shadow: 0 18px 40px rgba(6,14,30,.35); }
.auth-brand { text-align: center; color: #fff; margin-bottom: 1.25rem; }
.auth-brand .cdm-logo { font-size: 2rem; display: block; }
.auth-brand small { color: rgba(255,255,255,.6); letter-spacing: .04em; }

/* ---------- Misc ---------- */
.cdm-footer {
  padding: 1.5rem 0 2rem;
  color: #8a97a8;
  font-size: .8rem;
  text-align: center;
}
.form-label { font-weight: 600; font-size: .85rem; }
.text-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- Domain detail panel ---------- */
.domain-row { cursor: pointer; }
/* .offcanvas.domain-panel: needs to out-rank Bootstrap's own .offcanvas-end rules */
.offcanvas.domain-panel {
  /* Bootstrap sizes the offcanvas from this variable */
  --bs-offcanvas-width: min(94vw, max(380px, 25vw));
  --cdm-panel-gap: 10px;

  /* Floating card rather than a full-height slab */
  top: var(--cdm-panel-gap);
  right: var(--cdm-panel-gap);
  bottom: var(--cdm-panel-gap);
  height: auto;
  border: none;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(16, 24, 40, .22), 0 2px 6px rgba(16, 24, 40, .08);
  overflow: hidden;
  transform: translateX(calc(100% + var(--cdm-panel-gap) + 24px));
}
.offcanvas.domain-panel.show,
.offcanvas.domain-panel.showing { transform: none; }
.domain-panel .offcanvas-header {
  align-items: flex-start;
  gap: .75rem;
  padding: 1.1rem 1.35rem .9rem;
  border-bottom: 1px solid #eef1f6;
  background: linear-gradient(180deg, #fbfcfe 0%, #fff 100%);
}
.domain-panel .offcanvas-title { word-break: break-all; line-height: 1.25; }
.domain-panel .offcanvas-body { padding: 1.15rem 1.35rem 1.35rem; }
.domain-panel .detail-list { grid-template-columns: 8rem 1fr; gap: .5rem .85rem; }
.domain-panel .detail-list dt { font-size: .68rem; }
.domain-panel .detail-list dd { font-size: .87rem; }
.domain-panel .detail-actions .btn { flex: 1 1 auto; }

/* Softer dim behind the panel */
.offcanvas-backdrop.show { opacity: .25; }

.detail-list { display: grid; grid-template-columns: 8.5rem 1fr; gap: .45rem .75rem; margin: 0 0 1.25rem; }
.detail-list dt {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #6b7a90;
  font-weight: 700;
  padding-top: .12rem;
}
.detail-list dd { margin: 0; font-size: .9rem; color: #1d2733; word-break: break-word; }

.detail-section { border-top: 1px solid #eef1f6; padding-top: .9rem; margin-bottom: 1.25rem; }
.detail-section-title {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #6b7a90;
  font-weight: 700;
  margin-bottom: .4rem;
}
.detail-notes { font-size: .9rem; color: #33414f; margin: 0; white-space: pre-line; }
.detail-meta { font-size: .78rem; color: #98a4b5; margin-bottom: 1rem; }
.detail-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.domain-detail .detail-list { grid-template-columns: 10rem 1fr; }

/* ---------- Pagination ---------- */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-top: 1rem;
}
.pager-info { font-size: .8rem; color: #6b7a90; }
.pager-size { display: flex; align-items: center; gap: .5rem; }
.pager-size .form-label { font-size: .8rem; color: #6b7a90; }
.pager-size .form-select { width: auto; }
.pager .page-link { color: #2b3a4d; }
.pager .page-item.active .page-link { background: var(--cdm-accent); border-color: var(--cdm-accent); color: #fff; }

/* ---------- Add / edit form ---------- */
.form-page { max-width: 880px; margin: 0 auto; }
.form-page .card-body { padding: 1.5rem 1.75rem .5rem; }

.form-section { padding-bottom: 1.5rem; margin-bottom: 1.5rem; border-bottom: 1px solid #eef1f6; }
.form-section-last { border-bottom: none; margin-bottom: .5rem; }
.form-section-title {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #6b7a90;
  font-weight: 700;
  margin-bottom: 1rem;
}

.switch-tile {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  border: 1px solid #e3e8f0;
  border-radius: .5rem;
  padding: .6rem .75rem;
  margin-top: 1.55rem;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
  background: #fff;
}
.switch-tile:hover { border-color: #c7d3e4; }
.switch-tile:has(input:checked) { border-color: var(--cdm-accent); background: #f4f8ff; }
.switch-tile .form-check-input { margin: .1rem 0 0; flex: 0 0 auto; cursor: pointer; }
.switch-tile strong { display: block; font-size: .88rem; font-weight: 600; line-height: 1.2; }
.switch-tile small { display: block; font-size: .74rem; color: #8a97a8; line-height: 1.3; }

.form-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 1rem 1.75rem;
  border-top: 1px solid #eef1f6;
  background: #fbfcfe;
  border-radius: 0 0 .6rem .6rem;
}
@media (max-width: 575.98px) {
  .form-page .card-body { padding: 1.25rem 1.1rem .25rem; }
  .form-actions { padding: 1rem 1.1rem; flex-wrap: wrap; }
  .switch-tile { margin-top: 0; }
}
