:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f9fbfd;
  --border: #d9e0e8;
  --text: #15212e;
  --muted: #66758a;
  --brand: #274c77;
  --danger: #a42828;
  --ok: #0f7b4d;
  --shadow: 0 10px 28px rgba(20, 33, 46, 0.08);
  --page-max: 1860px;
  --input-bg: #ffffff;
  --table-head-bg: #f2f6fb;
  --field-border: #c7d1dc;
  --soft-border: #edf1f5;
}
html[data-theme="dark"] {
  --bg: #0b1118;
  --panel: #111a24;
  --panel-soft: #151f2b;
  --border: #2a3a4b;
  --text: #e7eef7;
  --muted: #a7b3c2;
  --brand: #9fc7f5;
  --danger: #f87171;
  --ok: #5ee0a0;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
  --input-bg: #0f1722;
  --table-head-bg: #182334;
  --field-border: #3a4a5e;
  --soft-border: #263648;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  justify-content: flex-start;
  gap: 0.65rem;
  align-items: stretch;
  padding: 0.85rem 1.5rem;
  background: var(--topbar-bg);
  color: var(--topbar-text);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 14px rgba(0,0,0,0.12);
}
.topbar-brand-row {
  grid-row: 1;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  min-width: 0;
}
.brand-wrap { display: flex; align-items: center; gap: 0.85rem; min-width: 0; }
.brand-copy { min-width: 0; }
.brand-logo { max-height: 42px; max-width: 180px; object-fit: contain; display: block; }
.brand-logo-secondary { width: 33px; height: 38px; max-width: 33px; max-height: 38px; object-fit: contain; display: block; flex: 0 0 33px; }
.brand { color: var(--topbar-text); font-weight: 850; font-size: 1.1rem; }
.tagline { display: block; color: var(--topbar-text); opacity: 0.75; font-size: 0.82rem; margin-top: 0.15rem; }
.topbar-link-row { grid-row: 2; grid-column: 1 / -1; display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; width: 100%; min-width: 0; }
.topbar-link-row a { color: var(--topbar-text); opacity: 0.9; font-weight: 700; }
.topbar-link-row a:hover { opacity: 1; }
.topbar-session { margin-left: auto; display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem; flex-wrap: wrap; text-align: right; }
.topbar-login { color: var(--topbar-text); font-weight: 800; border: 1px solid rgba(255,255,255,.35); border-radius: .5rem; padding: .4rem .7rem; }
.container { width: min(98vw, var(--page-max)); max-width: none; margin: 0 auto; padding: 1.25rem 0; }
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.panel-heading { display: flex; justify-content: space-between; align-items: start; gap: 1rem; margin-bottom: 1rem; }
.panel-heading.compact { align-items: center; margin-bottom: 0.5rem; }
h1, h2, h3 { margin: 0 0 0.35rem; line-height: 1.2; }
p { color: var(--muted); margin-top: 0; }
.search-grid, .grid.two, .settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 1rem;
}
.search-grid { grid-template-columns: repeat(3, minmax(220px, 1fr)); }
label { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 750; color: var(--text); min-width: 0; }
input, select, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  padding: 0.7rem 0.75rem;
  font: inherit;
  background: var(--input-bg);
  color: var(--text);
}
input[type="color"] { min-height: 45px; padding: 0.25rem; }
input[type="file"] { padding: 0.6rem 0.75rem; background: var(--input-bg); }
textarea { resize: vertical; min-height: 80px; }
fieldset {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  margin: 0 0 1rem;
}
legend { padding: 0 0.5rem; font-weight: 900; color: var(--brand); }
.button {
  border: 1px solid #b9c6d2;
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.2;
}
.button:hover { text-decoration: none; border-color: var(--brand-2); }
.button.primary { background: var(--brand-2); color: white; border-color: var(--brand-2); }
.button.secondary { background: #eef6ff; color: #174b78; }
.button.danger { color: white; border-color: var(--danger); background: var(--danger); }
.button.small { padding: 0.35rem 0.55rem; font-size: 0.82rem; }
.form-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
.search-actions { align-self: end; }
.sticky-actions { position: sticky; bottom: 0; background: rgba(255,255,255,0.95); padding: 1rem 0 0; border-top: 1px solid var(--border); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--border); padding: 0.75rem; text-align: left; vertical-align: top; }
th { background: var(--table-head-bg); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; }
.record-title { font-weight: 900; }
small { color: var(--muted); }
.pill { display: inline-flex; border-radius: 999px; padding: 0.2rem 0.55rem; background: #edf3f8; color: #2b4967; font-weight: 800; font-size: 0.83rem; }
.pill.large { font-size: 0.95rem; padding: 0.4rem 0.75rem; }
.empty-state { text-align: center; padding: 2rem; border: 1px dashed var(--border); border-radius: 14px; }
.empty-state.compact { padding: 1rem; text-align: left; }
.flash-wrap { margin-bottom: 1rem; }
.flash { border-radius: 12px; padding: 0.75rem 1rem; margin-bottom: 0.5rem; border: 1px solid var(--border); background: #fff; }
.flash.success { border-color: #a7d9c0; color: var(--ok); background: #effaf4; }
.flash.error { border-color: #e2a6a6; color: var(--danger); background: #fff1f1; }
.record-header { display: flex; justify-content: space-between; gap: 1rem; align-items: start; }
.header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(300px, 1fr)); gap: 1rem; align-items: start; }
dl { margin: 0; display: grid; gap: 0.75rem; }
.detail-field { border-bottom: 1px solid #edf1f5; padding-bottom: 0.65rem; }
dt { font-weight: 900; color: var(--text); margin-bottom: 0.18rem; }
dd { margin: 0; color: var(--text); white-space: normal; overflow-wrap: anywhere; }
.related-box { border: 1px solid #cfe0f1; background: #f8fbff; border-radius: 14px; padding: 1rem; margin-bottom: 1rem; }
.help-text { color: var(--muted); font-size: 0.86rem; font-weight: 500; }
.admin-wide { grid-column: 1 / -1; }
.inline-checkbox { flex-direction: row; align-items: center; gap: 0.5rem; }
.inline-checkbox input { width: auto; }
.admin-form-clean { align-items: start; }
.admin-forms-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  align-items: stretch;
}
.admin-forms-grid.two-cards { grid-template-columns: minmax(280px, 420px) 1fr; }
.admin-add-form.stacked {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  align-content: start;
  justify-items: stretch;
  padding: 1rem;
  border: 1px solid #e5edf5;
  border-radius: 14px;
  background: var(--panel-soft);
  min-width: 0;
}
.admin-add-form.stacked .button { justify-self: start; }
.readonly-card { background: #fff; }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(280px, 1fr)); gap: 1rem; align-items: start; }
.admin-card { min-width: 0; }
.option-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.4rem; }
.option-list li { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.55rem; border: 1px solid #edf1f5; border-radius: 10px; background: #fff; }
.option-list.compact-list { max-height: 18rem; overflow: auto; }
.option-list li > span { overflow-wrap: anywhere; min-width: 0; }
.custom-field-list code { color: var(--muted); }
.asset-select { min-height: 9rem; }
.logo-preview-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 0.75rem; border: 1px solid #edf1f5; border-radius: 12px; background: #fff; }
.logo-preview { max-height: 54px; max-width: 220px; object-fit: contain; }
.copy-friendly-output {
  width: 100%;
  min-height: 65vh;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  line-height: 1.45;
  white-space: pre;
}
.muted { color: var(--muted); opacity: 0.8; }
.login-page {
  width: min(520px, calc(100vw - 2rem));
  margin: 2rem auto 4rem;
  display: grid;
  gap: 1.5rem;
  justify-items: stretch;
}
.login-panel {
  max-width: none;
  margin: 0;
}
.login-form {
  display: grid;
  gap: 0.85rem;
}
.login-form label {
  gap: 0.45rem;
}
.login-actions {
  margin-top: 0.2rem;
}
.login-register-link {
  margin: 1.1rem 0 0;
}

.footer { width: min(98vw, var(--page-max)); max-width: none; margin: 0 auto; padding: 0 0 2rem; display: flex; justify-content: space-between; gap: 0.75rem; color: var(--muted); font-size: 0.85rem; }
@media (max-width: 1050px) {
  .search-grid, .admin-forms-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .panel-heading, .record-header, .footer { flex-direction: column; align-items: stretch; }
  .search-grid, .grid.two, .detail-grid, .admin-grid, .admin-forms-grid, .admin-forms-grid.two-cards, .settings-grid { grid-template-columns: 1fr; }
  .header-actions { align-items: stretch; }
  .header-actions .button, .header-actions form, .header-actions form button { width: 100%; }
}
.test-data-layout {
  display: grid;
  grid-template-columns: minmax(260px, 380px) 1fr;
  gap: 1rem;
  align-items: start;
}
.test-data-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}
.test-data-summary {
  border: 1px solid #edf1f5;
  background: var(--panel-soft);
  border-radius: 12px;
  padding: 0.85rem;
  min-height: 3.25rem;
}
.inline-counts {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.inline-counts li {
  border: 1px solid #d9e0e8;
  border-radius: 999px;
  background: #fff;
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
  color: var(--muted);
}
@media (max-width: 900px) {
  .test-data-layout { grid-template-columns: 1fr; }
}

.admin-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.admin-section-title h2 { margin: 0; }
.visibility-form h3 {
  margin: 1.25rem 0 0.5rem;
}
.visibility-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.5rem 1rem;
}
.visibility-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: #fff;
}
.visibility-item input { width: auto; }

.nav-user { color: var(--topbar-text); opacity: .9; font-size: .9rem; padding: .45rem .25rem; }
.inline-logout { display: inline; margin: 0; }
.inline-logout button { background: transparent; color: var(--topbar-text); border: 1px solid rgba(255,255,255,.35); border-radius: .5rem; padding: .4rem .7rem; cursor: pointer; }
.actions-cell { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.actions-cell input[type="password"] { min-width: 12rem; }
.table-wrap input, .table-wrap select { width: 100%; min-width: 8rem; }

.registration-settings-form {
  border: 1px solid var(--border, #d7dde5);
  background: rgba(0,0,0,0.015);
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: 1.25rem;
}
.readonly-list li { justify-content: flex-start; }

.section-divider { border: 0; border-top: 1px solid var(--border, #d9e2ec); margin: 1rem 0; }
.sso-actions { margin-bottom: 0.5rem; }

.readonly-comments {
  min-width: 18rem;
  max-height: 12rem;
  overflow: auto;
  white-space: normal;
  border: 1px solid var(--border, #d7dde5);
  background: #f8fafc;
  border-radius: 10px;
  padding: 0.65rem;
  color: var(--text, #0f172a);
  margin-bottom: 0.65rem;
}
.inline-comment-form {
  display: grid;
  gap: 0.45rem;
  min-width: 18rem;
  margin: 0;
}
.inline-comment-form textarea {
  min-width: 18rem;
  resize: vertical;
}
.compact-label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.9rem;
  margin: 0;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.row-actions form {
  margin: 0;
}

/* ITHC action controls: keep edit/delete visible near the start of wide RAP tables. */
.actions-cell {
  min-width: 128px;
  vertical-align: top;
}
.row-actions-stack {
  align-items: flex-start;
  gap: 0.35rem;
}
.row-actions-stack form {
  margin: 0;
}
.finding-title-cell {
  min-width: 220px;
  font-weight: 650;
}
.text-link {
  display: inline-block;
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: var(--accent-color);
  font-weight: 650;
  text-decoration: none;
}
.text-link:hover {
  text-decoration: underline;
}

.ithc-action-list {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 1rem;
}
.ithc-action-card {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  background: #f8fafc;
}
.ithc-action-card .muted {
  display: block;
  margin-top: 0.15rem;
}
@media (max-width: 760px) {
  .ithc-action-card {
    align-items: flex-start;
    flex-direction: column;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.inline-form.compact-form {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}
.inline-form.compact-form select {
  min-width: 10rem;
}

.form-control {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 750;
  color: var(--text);
  min-width: 0;
}
.field-label { font-weight: 750; }
.multi-select-dropdown {
  position: relative;
  width: 100%;
}
.multi-select-dropdown summary {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  padding: 0.7rem 0.75rem;
  font: inherit;
  background: var(--input-bg);
  color: var(--text);
  cursor: pointer;
  list-style: none;
  min-height: 2.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.multi-select-dropdown summary::-webkit-details-marker { display: none; }
.multi-select-dropdown summary::after {
  content: "▾";
  float: right;
  color: var(--muted);
}
.multi-select-dropdown[open] summary::after { content: "▴"; }
.multi-select-options {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  margin-top: 0.35rem;
  max-height: 18rem;
  overflow: auto;
  border: 1px solid #c7d1dc;
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 0.45rem;
}
.multi-select-option {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.55rem;
  border-radius: 8px;
  font-weight: 650;
  cursor: pointer;
}
.multi-select-option:hover { background: #f2f6fb; }
.multi-select-option input { width: auto; }
.context-block + .context-block {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.preline {
  white-space: pre-line;
}

.tenable-import-table td {
  vertical-align: top;
}

.tenable-row-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  min-width: 5.5rem;
}

.tenable-row-actions form {
  margin: 0;
}

.danger-pill {
  background: #fee2e2;
  color: #991b1b;
}

.admin-jump-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.admin-jump-nav a {
  display: inline-block;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font-weight: 700;
}

section.panel[id] {
  scroll-margin-top: 6rem;
}

.tenable-import-table {
  table-layout: auto;
}

.tenable-import-table td:last-child,
.tenable-import-table th:last-child {
  min-width: 7rem;
  width: 7rem;
}


.env-os-asset-section {
  border: 1px solid var(--border, #d8dee9);
  border-radius: 10px;
  padding: 1rem;
  margin: 1rem 0;
  background: #fafbfc;
}
.env-os-asset-box {
  display: block;
  margin: 0.75rem 0;
}
.env-os-asset-box[hidden] {
  display: none !important;
}
.env-os-asset-box textarea {
  margin-top: 0.35rem;
}
.muted-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: #eef1f5;
  color: #5d6573;
  font-size: 0.8rem;
}

.os-option[hidden],
.multi-select-option[hidden] {
  display: none !important;
}

.cve-compact {
  white-space: nowrap;
  display: inline-block;
  max-width: 18rem;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.cve-cell {
  min-width: 12rem;
  max-width: 18rem;
}
.cve-compact,
.cve-compact a,
.cve-cell {
  white-space: nowrap !important;
  word-break: keep-all;
  overflow-wrap: normal;
}
.cve-compact {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}
.status-pill {
  white-space: nowrap;
}
.severity-pill {
  white-space: nowrap;
}
.severity-critical { background: #fee2e2; color: #991b1b; }
.severity-high { background: #ffedd5; color: #9a3412; }
.severity-medium { background: #fef3c7; color: #92400e; }
.severity-low { background: #dbeafe; color: #1e40af; }
.severity-informational { background: #e5e7eb; color: #374151; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-weight: 800;
  font-size: 0.82rem;
  background: #edf3f8;
  color: #2b4967;
}
.badge.success { background: #effaf4; color: var(--ok); border: 1px solid #a7d9c0; }
.badge.warning { background: #fff8e6; color: #8a5a00; border: 1px solid #f2d58a; }
.wide-table table { min-width: 1100px; }
.compact-form { display: grid; gap: 0.45rem; min-width: 16rem; }
.compact-form textarea { width: 100%; min-width: 14rem; }
.checkbox-line { display: flex; flex-direction: row; align-items: center; gap: 0.4rem; font-weight: 650; }
.checkbox-line input { width: auto; }
.preserve-lines { white-space: pre-wrap; overflow-wrap: anywhere; }

/* CIS benchmark results */
.cis-upload-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin: 0.75rem 0 1rem;
}
.cis-upload-summary > div {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-soft);
  padding: 0.75rem;
  display: grid;
  gap: 0.25rem;
}
.cis-upload-summary strong { color: #33465d; }
.cis-upload-summary span { overflow-wrap: anywhere; }
.section-jump-links { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.section-jump-links a {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  background: #fff;
  font-weight: 800;
}
.cis-result-list { display: grid; gap: 0.85rem; }
.cis-result-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  padding: 0.9rem;
  box-shadow: 0 4px 14px rgba(20, 33, 46, 0.04);
}
.cis-result-card.cis-fail { border-left: 5px solid #d97706; }
.cis-result-card.cis-pass { border-left: 5px solid #16a34a; }
.cis-result-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  margin-bottom: 0.75rem;
}
.cis-control { min-width: 0; }
.cis-control h3 { font-size: 1rem; margin: 0.2rem 0 0; overflow-wrap: anywhere; }
.cis-control-id {
  font-weight: 900;
  color: #0f1f33;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.cis-result-badges { display: flex; gap: 0.35rem; flex-wrap: wrap; justify-content: end; }
.cis-result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}
.compact-results .cis-result-grid { grid-template-columns: 1fr; }
.cis-text-panel {
  border: 1px solid #edf1f5;
  border-radius: 12px;
  background: var(--panel-soft);
  padding: 0.75rem;
  min-width: 0;
}
.cis-text-panel h4 { margin: 0 0 0.35rem; color: #33465d; }
.cis-text-block {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.45;
  max-height: 12rem;
  overflow: auto;
  color: #15212e;
}
.cis-result-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  border-top: 1px solid #edf1f5;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
}
.cis-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: start; justify-content: end; }
.cis-actions details { position: relative; }
.details-form { margin-top: 0.5rem; }
.block-text { display: block; margin-top: 0.25rem; }
@media (max-width: 900px) {
  .cis-result-header, .cis-result-footer { flex-direction: column; align-items: stretch; }
  .cis-result-grid { grid-template-columns: 1fr; }
  .cis-result-badges, .cis-actions { justify-content: start; }
}

/* Reporting / charts */
.chart-builder { display: flex; flex-direction: column; gap: 1rem; }
.grid.three { display: grid; grid-template-columns: repeat(3, minmax(220px, 1fr)); gap: 1rem; }
.checkbox-row { flex-direction: row; align-items: center; justify-content: flex-start; gap: 0.55rem; }
.checkbox-row input[type="checkbox"] { width: auto; min-width: auto; }
.chart-toggle { align-self: end; min-height: 44px; }
.filter-details { border: 1px solid var(--border); border-radius: 14px; padding: 1rem; background: var(--panel-soft); }
.filter-details summary { cursor: pointer; font-weight: 900; color: var(--brand); }
.chart-filter-grid { display: grid; grid-template-columns: repeat(4, minmax(190px, 1fr)); gap: 1rem; margin-top: 1rem; }
.chart-filter-grid select[multiple] { min-height: 9rem; padding: 0.45rem; }
.chart-card { border: 1px solid var(--border); border-radius: 14px; background: #fff; padding: 1rem; margin-bottom: 1rem; overflow: hidden; }
.chart-card canvas { display: block; width: 100%; max-width: 100%; }
.chart-table-wrap { overflow-x: auto; }
.bar-inline { display: inline-block; min-width: 160px; width: min(220px, 60vw); height: 0.7rem; background: #e8eef5; border-radius: 999px; overflow: hidden; vertical-align: middle; margin-right: 0.5rem; }
.bar-inline span { display: block; height: 100%; background: var(--brand-2); border-radius: 999px; }
@media (max-width: 1100px) {
  .chart-filter-grid { grid-template-columns: repeat(2, minmax(190px, 1fr)); }
  .grid.three { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
}
@media (max-width: 720px) {
  .chart-filter-grid, .grid.three { grid-template-columns: 1fr; }
}

/* Customer overview */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.metric-card {
  background: var(--panel, #fff);
  border: 1px solid var(--border, #d8e0e8);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.metric-card .metric-label {
  display: block;
  color: var(--muted, #667085);
  font-size: 0.88rem;
  margin-bottom: 0.35rem;
}
.metric-card strong {
  display: block;
  font-size: 2rem;
  line-height: 1.1;
  margin-bottom: 0.35rem;
}
.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
}
.context-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.context-box {
  border: 1px solid var(--border, #d8e0e8);
  border-radius: 12px;
  padding: 1rem;
  background: var(--surface-muted, #f8fafc);
}
.context-box h3 {
  margin-top: 0;
}
.context-box p {
  margin-bottom: 0;
}
.customer-chart-card {
  min-height: 340px;
}
@media (max-width: 900px) {
  .split-grid {
    grid-template-columns: 1fr;
  }
}

.customisation-table-wrap { max-height: 72vh; overflow: auto; }
.customisation-table th { position: sticky; top: 0; z-index: 1; }
.customisation-table textarea { min-height: 4.5rem; min-width: 18rem; }
.customisation-row-form { margin: 0; }
.ui-default-text { font-weight: 800; overflow-wrap: anywhere; }



/*
  Global form and control spacing.
  Several pages combine buttons, helper text, fieldsets and tables in tight
  sequences. These rules provide a consistent vertical rhythm without needing
  each individual template to carry one-off spacer classes.
*/
:root {
  --space-xs: 0.35rem;
  --space-sm: 0.6rem;
  --space-md: 0.85rem;
  --space-lg: 1.1rem;
  --space-xl: 1.45rem;
}

.panel > p,
.panel-heading p {
  margin-bottom: var(--space-md);
}

.panel > form,
.panel > .filters,
.panel > .record-form,
.panel > .settings-grid,
.panel > .admin-form-clean {
  margin-bottom: var(--space-lg);
}

.panel > form:last-child,
.panel > .filters:last-child,
.panel > .record-form:last-child,
.panel > .settings-grid:last-child,
.panel > .admin-form-clean:last-child {
  margin-bottom: 0;
}

.record-form,
.admin-form-clean {
  display: grid;
  gap: var(--space-lg);
}

.settings-grid.admin-form-clean,
.search-grid.admin-form-clean {
  gap: var(--space-lg);
}

.filters,
.compact-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-md);
  margin: var(--space-md) 0 var(--space-lg);
}

.filters input,
.filters select,
.compact-filters input,
.compact-filters select {
  width: auto;
  min-width: min(16rem, 100%);
}

.filters .button,
.compact-filters .button {
  min-height: 2.85rem;
}

.form-actions {
  margin-top: var(--space-sm);
  margin-bottom: var(--space-md);
}

.form-actions:last-child {
  margin-bottom: 0;
}

.form-actions + .table-wrap,
form + .table-wrap,
.filters + .table-wrap,
.compact-filters + .table-wrap,
.search-grid + .table-wrap,
.record-form + .table-wrap,
.settings-grid + .table-wrap,
.admin-form-clean + .table-wrap {
  margin-top: var(--space-lg);
}

.form-actions + h2,
.form-actions + h3,
form + h2,
form + h3,
.table-wrap + h2,
.table-wrap + h3 {
  margin-top: var(--space-xl);
}

h2 + .table-wrap,
h3 + .table-wrap,
.panel-heading + .table-wrap {
  margin-top: var(--space-md);
}

.table-wrap {
  margin-top: var(--space-md);
}

.table-wrap:first-child,
.panel-heading + .table-wrap {
  margin-top: 0;
}

fieldset > .button,
fieldset > .form-actions {
  margin-top: var(--space-lg);
}

fieldset > .grid + .button,
fieldset > .grid + .form-actions,
fieldset > .settings-grid + .button,
fieldset > .settings-grid + .form-actions {
  margin-top: var(--space-lg);
}

.help-text,
.muted.block-text,
.block-text {
  margin-top: var(--space-xs);
}

label .help-text,
label small {
  margin-top: 0.15rem;
}

p + .form-actions,
p + .button,
p + form,
p + .table-wrap {
  margin-top: var(--space-md);
}

.button + .table-wrap,
.button + table,
.button + h2,
.button + h3 {
  margin-top: var(--space-lg);
}

.panel > :last-child {
  margin-bottom: 0;
}

@media (max-width: 760px) {
  .filters,
  .compact-filters,
  .form-actions {
    align-items: stretch;
  }
  .filters input,
  .filters select,
  .filters .button,
  .compact-filters input,
  .compact-filters select,
  .compact-filters .button,
  .form-actions .button,
  .form-actions button,
  .form-actions select {
    width: 100%;
  }
}

/* Layout and dark mode refinements */
.theme-toggle {
  background: transparent;
  color: var(--topbar-text);
  border: 1px solid rgba(255,255,255,.35);
  border-radius: .5rem;
  padding: .4rem .7rem;
  cursor: pointer;
  font-weight: 800;
}
.theme-toggle:hover { border-color: rgba(255,255,255,.7); }

html[data-theme="dark"] a { color: #8cc8ff; }
html[data-theme="dark"] .topbar a,
html[data-theme="dark"] .brand,
html[data-theme="dark"] .topbar-link-row a { color: var(--topbar-text); }
html[data-theme="dark"] .panel,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .chart-card,
html[data-theme="dark"] .cis-result-card,
html[data-theme="dark"] .readonly-card,
html[data-theme="dark"] .admin-add-form.stacked,
html[data-theme="dark"] .context-box,
html[data-theme="dark"] .related-box,
html[data-theme="dark"] .env-os-asset-section,
html[data-theme="dark"] .test-data-summary,
html[data-theme="dark"] .cis-text-panel,
html[data-theme="dark"] .readonly-comments,
html[data-theme="dark"] .ithc-action-card,
html[data-theme="dark"] .filter-details,
html[data-theme="dark"] .logo-preview-row,
html[data-theme="dark"] .multi-select-options {
  background: var(--panel-soft);
  border-color: var(--border);
  color: var(--text);
}
html[data-theme="dark"] .panel { background: var(--panel); }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea { background: var(--input-bg); color: var(--text); border-color: var(--field-border); }
html[data-theme="dark"] .button { background: var(--input-bg); color: var(--text); border-color: var(--field-border); }
html[data-theme="dark"] .button.primary { background: var(--brand-2); color: #fff; border-color: var(--brand-2); }
html[data-theme="dark"] .button.secondary { background: #132b43; color: #cfe8ff; border-color: #284761; }
html[data-theme="dark"] .button.danger { background: #991b1b; color: #fff; border-color: #991b1b; }
html[data-theme="dark"] .flash { background: var(--panel-soft); color: var(--text); }
html[data-theme="dark"] .flash.success { background: #0e2a1d; color: #a7f3d0; border-color: #14532d; }
html[data-theme="dark"] .flash.error { background: #321313; color: #fecaca; border-color: #7f1d1d; }
html[data-theme="dark"] .pill,
html[data-theme="dark"] .badge,
html[data-theme="dark"] .muted-badge,
html[data-theme="dark"] .inline-counts li { background: #1f2d3d; color: #cbd5e1; border-color: var(--border); }
html[data-theme="dark"] .option-list li,
html[data-theme="dark"] .visibility-item,
html[data-theme="dark"] .admin-jump-nav a,
html[data-theme="dark"] .section-jump-links a { background: var(--input-bg); border-color: var(--border); }
html[data-theme="dark"] .detail-field,
html[data-theme="dark"] th,
html[data-theme="dark"] td { border-color: var(--border); }
html[data-theme="dark"] .multi-select-dropdown summary { background: var(--input-bg); color: var(--text); border-color: var(--field-border); }
html[data-theme="dark"] .multi-select-option:hover { background: #1a2838; }
html[data-theme="dark"] .sticky-actions { background: rgba(17,26,36,0.96); border-color: var(--border); }
html[data-theme="dark"] .cis-control-id,
html[data-theme="dark"] .cis-upload-summary strong,
html[data-theme="dark"] .cis-text-panel h4 { color: var(--text); }
html[data-theme="dark"] .cis-text-block { color: var(--text); }
html[data-theme="dark"] canvas { color-scheme: dark; }

/* Dependency-free trend chart */
.trend-chart-card {
  min-height: 450px;
  background: var(--panel-soft);
}
.trend-chart-svg {
  display: block;
  width: 100%;
  height: 420px;
}
.trend-chart-bg {
  fill: var(--panel-soft);
}
.trend-grid-line {
  stroke: var(--border);
  stroke-width: 1;
  opacity: 0.85;
}
.trend-grid-line-vertical {
  opacity: 0.35;
}
.trend-axis-line {
  stroke: var(--muted);
  stroke-width: 1.4;
  opacity: 0.8;
}
.trend-axis-label,
.trend-value-label,
.trend-legend {
  fill: var(--text);
  font-size: 13px;
  font-weight: 700;
}
.trend-value-label {
  fill: var(--muted);
  font-size: 12px;
}
.trend-line {
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.trend-line.created,
.trend-point.created {
  stroke: var(--brand-2);
  fill: var(--brand-2);
}
.trend-line.closed,
.trend-point.closed {
  stroke: #16a34a;
  fill: #16a34a;
}
html[data-theme="dark"] .trend-line.closed,
html[data-theme="dark"] .trend-point.closed {
  stroke: #4ade80;
  fill: #4ade80;
}
.chart-fallback {
  margin-bottom: 1rem;
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 760px) {
  .topbar-brand-row { align-items: flex-start; flex-direction: column; }
  .topbar-session { margin-left: 0; justify-content: flex-start; text-align: left; }
}

.login-large-logo-wrap {
  width: 100%;
  margin: 0;
  text-align: center;
}
.login-large-logo {
  display: inline-block;
  max-width: min(420px, 100%);
  max-height: 180px;
  width: auto;
  height: auto;
  object-fit: contain;
}
@media (max-width: 640px) {
  .login-page {
    width: min(100%, calc(100vw - 1rem));
    margin-top: 1rem;
    gap: 1.25rem;
  }
  .login-large-logo {
    max-width: min(340px, 92vw);
    max-height: 150px;
  }
}

.logo-preview-secondary { width: 33px; height: 38px; object-fit: contain; }
.logo-preview-login { max-width: 320px; max-height: 140px; object-fit: contain; }
