/*! © 2026 Cyber Affinity LLC. All rights reserved. Use is subject to https://www.cyber-affinity.com/terms — copying or redistributing this code is not permitted. */
/* Defense Stack Map — styles are scoped under .ds so they never leak into the shared site styles. */
.ds {
  --sunk: var(--bg-alt);
  --ink: var(--text);
  --accent-soft: rgba(45, 212, 191, 0.12);
  --ok: #2dd4bf; --ok-soft: rgba(45, 212, 191, 0.14);
  --warn: #fde047; --warn-soft: rgba(253, 224, 71, 0.14);
  --bad: #fca5a5; --bad-soft: rgba(248, 113, 113, 0.15);
  --plan: #93c5fd; --plan-soft: rgba(96, 165, 250, 0.18);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --shadow: 0 12px 32px rgb(0 0 0 / 0.45);
  font-size: 15px; line-height: 1.5;
}
.ds-page { padding: 48px 0 72px; }
.ds-wrap { max-width: 1300px; display: grid; gap: 18px; }
.ds [hidden] { display: none !important; }
.ds h2 { font-size: 20px; margin: 0; letter-spacing: -0.005em; line-height: 1.25; }
.ds h3 { font-size: 17px; margin: 0; }
.ds p { margin: 0; }
.ds label { display: inline; font-weight: inherit; font-size: inherit; }
.ds .lede { margin-bottom: 0; }
.ds :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ds .mono, .ds .score { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.ds .ds-eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.ds .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ds .ds-hint { font-size: 13px; color: var(--muted); }

/* Intro + toolbar */
.ds-intro { display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: flex-end; justify-content: space-between; }
.ds-intro-text { min-width: 0; max-width: 680px; }
.ds-intro h1 { margin-bottom: 10px; }
.ds-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.ds .field { display: grid; gap: 4px; min-width: 0; }
.ds .field > label, .ds .field > .ds-flabel { font-size: 12px; color: var(--muted); }
.ds .input { border: 1px solid var(--line); background: var(--sunk); border-radius: 8px; padding: 7px 10px; min-width: 0; width: 100%; font-size: 14px; }
.ds .input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.ds textarea.input { resize: vertical; min-height: 96px; font-family: var(--mono); font-size: 13px; }
.ds .btn { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.ds .btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.ds .ds-quiet { border-color: transparent; color: var(--muted); }
.ds .ds-danger { color: var(--bad); }

details.ds-menu { position: relative; }
details.ds-menu > summary { list-style: none; }
details.ds-menu > summary::-webkit-details-marker { display: none; }
.ds .ds-menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: grid; gap: 2px; width: min(290px, 86vw); box-shadow: var(--shadow); }
.ds .ds-menu-item { display: grid; gap: 1px; text-align: left; border: 0; background: transparent; border-radius: 6px; padding: 8px 10px; cursor: pointer; color: var(--ink); font: inherit; font-size: 14px; }
.ds .ds-menu-item:hover, .ds .ds-menu-item:focus-visible { background: var(--sunk); }
.ds .ds-menu-item span { font-size: 12px; color: var(--muted); }

.ds .ds-banner { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; background: var(--accent-soft); border-radius: 10px; padding: 12px 16px; }
.ds .ds-banner p { max-width: 70ch; color: var(--text); }
.ds .ds-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Cards */
.ds .ds-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.ds .ds-card-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.ds .ds-card-head .ds-title { display: grid; gap: 2px; min-width: 0; }

.ds .ds-main { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 960px) { .ds .ds-main { grid-template-columns: minmax(0, 1fr); } }

/* Environment toggles */
.ds .segctl { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.ds .segctl button { border: 0; background: transparent; padding: 6px 11px; font: inherit; font-size: 13px; cursor: pointer; color: var(--muted); }
.ds .segctl button + button { border-left: 1px solid var(--line); }
.ds .segctl button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.ds .segctl button[aria-pressed="false"] { text-decoration: line-through; text-decoration-thickness: 1px; }
.ds .envpick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ds .envlbl { font-size: 12px; color: var(--muted); }
.ds .head-ctl { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Map + ledger layout */
.ds .map-scroll { overflow-x: auto; margin-inline: -6px; }
.ds .map-body { display: grid; gap: 20px; }
.ds .map-col { min-width: 0; }
.ds .ds-main.wide { grid-template-columns: minmax(0, 1fr); }
.ds .ds-main.wide .map-body { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
.ds .ds-main.wide .map-col { position: sticky; top: 80px; }
.ds .ds-main.wide .ds-panel { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); align-items: start; }
.ds .ds-main.wide .ds-panel .detail { border-top: 0; padding-top: 0; border-left: 1px solid var(--line); padding-left: 20px; }
@media (max-width: 1040px) { .ds .ds-main.wide .map-body { grid-template-columns: minmax(0, 1fr); } .ds .ds-main.wide .map-col { position: static; } }
@media (max-width: 860px) { .ds .ds-main.wide .ds-panel { grid-template-columns: minmax(0, 1fr); } .ds .ds-main.wide .ds-panel .detail { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 16px; } }

#map svg { display: block; width: 100%; min-width: 640px; height: auto; }
#map .seg { cursor: pointer; }
#map .seg:hover polygon { opacity: 0.86; }
#map .seg:focus { outline: none; }
#map .seg:focus-visible polygon { stroke: var(--accent); stroke-width: 2; }
#map .lbl { cursor: pointer; }
.ds .legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.ds .legend span { display: inline-flex; align-items: center; gap: 6px; }
.ds .legend .ds-legend-note { flex-basis: 100%; }
.ds .sw { width: 14px; height: 14px; border-radius: 3px; display: inline-block; border: 1px solid rgb(255 255 255 / 0.12); }
.ds .sw.in { background: #2dd4bf; } .ds .sw.part { background: #fde047; } .ds .sw.plan { background: #60a5fa; }
.ds .sw.gap { background: #f87171; } .ds .sw.na { background: #2a4a6b; }
.ds .ds-stats { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.ds .ds-stats b { font-family: var(--mono); font-weight: 500; color: var(--ink); }
.ds .ds-stats b.ds-bad { color: var(--bad); }

.ds .ledger { display: grid; border-top: 1px solid var(--line); min-width: 0; }
.ds .ledger .legend { margin: 8px 0 2px; }
.ds .lrow { display: grid; gap: 6px; padding: 8px 8px 10px; border-bottom: 1px solid var(--line); }
.ds .lrow.sel { background: var(--accent-soft); border-radius: 8px; border-bottom-color: transparent; }
.ds .lhead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; width: 100%; color: var(--ink); font: inherit; }
.ds .lhead .nm { font-weight: 600; font-size: 14px; }
.ds .lgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.ds .lgrid.one { grid-template-columns: minmax(0, 1fr); }
.ds .lcol { display: grid; gap: 4px; align-content: start; min-width: 0; }
.ds .lenv { font-size: 10.5px; font-family: var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.ds .lmix { font-size: 12px; color: var(--muted); text-transform: none; letter-spacing: 0; font-family: var(--font); margin-left: 6px; }
.ds .lchips { display: flex; flex-wrap: wrap; gap: 5px; min-width: 0; }
.ds .lchip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 1px 8px; font: inherit; font-size: 12px; cursor: pointer; max-width: 100%; overflow-wrap: anywhere; text-align: left; }
.ds .lchip:hover { border-color: var(--muted); }
.ds .lchip.more { color: var(--accent); border-style: dashed; }
.ds .lchip.gap { background: var(--bad-soft); color: var(--bad); border-color: transparent; cursor: default; }
.ds .lchip.miss { background: transparent; color: var(--bad); border: 1px dashed rgb(248 113 113 / 0.7); }

/* Add control + selected layer */
.ds .ds-panel { display: grid; gap: 18px 20px; }
.ds .qa { position: relative; display: grid; gap: 8px; }
.ds .qa-anchor { position: relative; }
.ds .qa-row { display: flex; gap: 8px; }
.ds .qa-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 15; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 4px; margin: 0; list-style: none; max-height: 320px; overflow: auto; }
.ds .qa-list li { padding: 7px 10px; border-radius: 6px; cursor: pointer; display: grid; gap: 1px; }
.ds .qa-list li small { color: var(--muted); font-size: 12px; }
.ds .qa-list li[aria-selected="true"] { background: var(--sunk); }
.ds .bulk summary { cursor: pointer; color: var(--accent); font-size: 14px; width: fit-content; }
.ds .bulk[open] summary { margin-bottom: 8px; }
.ds .bulk .ds-row { justify-content: space-between; margin-top: 8px; }

.ds .detail { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 16px; }
.ds .detail-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.ds .ds-desc { font-size: 14px; color: var(--muted); }
.ds .ds-fit { width: fit-content; }
.ds .pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; border-radius: 999px; padding: 2px 9px; font-weight: 600; white-space: nowrap; }
.ds .pill.covered { background: var(--ok-soft); color: var(--ok); }
.ds .pill.partial { background: var(--warn-soft); color: var(--warn); }
.ds .pill.gap { background: var(--bad-soft); color: var(--bad); }
.ds .pill.na, .ds .pill.neutral { background: var(--sunk); color: var(--muted); }
.ds .pill.planned { background: var(--plan-soft); color: var(--plan); }
.ds .caps { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.ds .cap { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--sunk); }
.ds .cap.missing { border-color: rgb(248 113 113 / 0.5); }
.ds .cap.off { opacity: 0.6; }
.ds .cap .cn { display: flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 600; min-width: 0; }
.ds .cap .cv { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.ds .cap .cv b { font-weight: 500; color: var(--ink); }
.ds .cap .ref { opacity: 0.8; font-family: var(--mono); font-size: 11.5px; }
.ds .cap select { padding: 3px 6px; font-size: 12.5px; width: auto; }
.ds .cap .add { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.ds details.beyond > summary { cursor: pointer; color: var(--accent-2); font-size: 14px; width: fit-content; }
.ds details.beyond[open] > summary { margin-bottom: 4px; }
.ds details.beyond .ds-hint { margin: 6px 0 8px; }
.ds .list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.ds .list button { width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 7px 10px; display: flex; gap: 8px; align-items: center; justify-content: space-between; cursor: pointer; font: inherit; font-size: 14px; }
.ds .list button:hover { border-color: var(--muted); }
.ds .list .nm { min-width: 0; overflow-wrap: anywhere; }
.ds .suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.ds .suggest button { border: 1px dashed var(--line); background: transparent; color: var(--ink); border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.ds .suggest button:hover { border-style: solid; border-color: var(--accent); color: var(--accent); }
.ds .ds-note { font-size: 13px; background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 8px 10px; display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

.ds .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.ds .dot.implemented { background: #2dd4bf; } .ds .dot.partial { background: #fde047; } .ds .dot.planned { background: #60a5fa; }
.ds .dot.missing { background: transparent; border: 1.5px solid #f87171; }

/* Pillars + threats */
.ds .pillars { display: grid; grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); gap: 10px; }
.ds .ptile { border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; display: grid; gap: 6px; align-content: start; background: var(--surface); }
.ds .ptile.gap { background: var(--bad-soft); border-color: transparent; }
.ds .ptile .nm { font-weight: 600; font-size: 14px; line-height: 1.3; }
.ds .ptile .meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.ds .ptile .n { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.ds .ptile .sub { display: flex; gap: 4px; flex-wrap: wrap; }
.ds .pbar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--sunk); }
.ds .pbar i { display: block; height: 100%; }
.ds .pbar i.implemented { background: #2dd4bf; } .ds .pbar i.partial { background: #fde047; } .ds .pbar i.planned { background: #60a5fa; }
.ds .threats { display: flex; flex-wrap: wrap; gap: 8px; }
.ds .tchip { display: inline-flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 13px; }
.ds .tchip b { font-family: var(--mono); font-weight: 500; background: var(--sunk); border-radius: 999px; padding: 0 8px; min-width: 26px; text-align: center; }
.ds .tchip.zero { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.ds .tchip.zero b { background: transparent; }

/* Inventory */
.ds .inv-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ds .inv-tools .input { width: 220px; }
.ds .tbl-wrap { overflow-x: auto; }
.ds table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ds th { font-weight: 600; text-align: left; font-size: 12px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: transparent; }
.ds td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ds tr.ds-row { cursor: pointer; display: table-row; }
.ds tr.ds-row:hover td, .ds tr.ds-row.open td { background: var(--sunk); }
.ds td.name { min-width: 180px; overflow-wrap: anywhere; }
.ds .badge { font-size: 11px; font-family: var(--mono); letter-spacing: 0.04em; background: var(--warn-soft); color: var(--warn); border-radius: 4px; padding: 1px 6px; margin-left: 6px; white-space: nowrap; }
.ds .status { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.ds tr.editor td { background: var(--sunk); padding: 4px 10px 16px; }
.ds .edit { display: grid; gap: 14px; }
.ds .edit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.ds .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ds .chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 3px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.ds .chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ds .edit-foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.ds .ds-empty { padding: 24px; text-align: center; color: var(--muted); }

.ds-toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--text); color: var(--bg); border-radius: 10px; padding: 10px 14px; font-size: 14px; display: flex; gap: 12px; align-items: center; box-shadow: 0 12px 32px rgb(0 0 0 / 0.45); z-index: 50; max-width: calc(100vw - 32px); }
.ds-toast[hidden] { display: none; }
.ds-toast button { background: transparent; border: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; font-weight: 600; }

@media (max-width: 560px) { .ds .ds-card { padding: 14px; } .ds .inv-tools .input { width: 100%; } }
@media (prefers-reduced-motion: no-preference) { .ds .chip, .ds .list button, .ds .lchip { transition: border-color 0.15s, background 0.15s; } }
.ds .ds-menu-item:disabled { cursor: not-allowed; opacity: .6; }
.ds .ds-menu-item:disabled:hover { background: transparent; }
@media (max-width: 600px) {
  .ds .ds-actions { position: relative; }
  .ds details.ds-menu { position: static; }
  .ds .ds-menu-list { left: 0; right: 0; width: auto; }
}
