:root {
  --brand: #0f9d8c;
  --brand-2: #0a7b70;
  --brand-deep: #075851;
  --brand-glow: rgba(15, 157, 140, 0.14);
  --accent: #d96c47;

  --bg: #f5f1e8;
  --bg-2: #fffaf2;
  --panel: rgba(255, 250, 242, 0.82);
  --panel-2: #fffdf8;
  --panel-3: #f4ecde;
  --border: #d9cbb7;
  --border-soft: #eadfce;
  --text: #1f2a2d;
  --muted: #6f7b78;
  --primary: var(--brand);
  --primary-hover: #13b4a1;
  --on-primary: #f5fffd;
  --danger: #c65353;
  --ok: #238b61;

  /* graph / entity colours (kept, nudged toward the palette) */
  --account: #f5a524;
  --user: #38bdf8;
  --group: #a78bfa;
  --role: #2dd4bf;
  --managed: #f472b6;
  --inline: #fb923c;

  --radius: 18px;
  --shadow: 0 18px 45px -28px rgba(69, 54, 32, 0.35);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Space Grotesk", var(--font);
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
/* The `hidden` attribute must win over our display:flex layout rules below,
   otherwise every view/tabpane renders at once. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1200px 680px at 100% -10%, rgba(217, 108, 71, 0.11), transparent 60%),
    radial-gradient(900px 520px at -5% 110%, rgba(15, 157, 140, 0.10), transparent 58%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.52), rgba(255, 255, 255, 0)),
    var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}
::selection { background: var(--brand-glow); }

/* Custom scrollbars to match the dark theme */
* { scrollbar-width: thin; scrollbar-color: #c9baa4 transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #c9baa4; border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #b8a58a; background-clip: content-box; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
  padding: 16px 28px;
  background: rgba(245, 241, 232, 0.76);
  border-bottom: 1px solid rgba(217, 203, 183, 0.8);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 38px; width: auto; display: block; filter: drop-shadow(0 10px 18px rgba(15, 157, 140, 0.18)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name {
  font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: .3px;
  background: linear-gradient(90deg, var(--brand-deep), var(--brand));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.brand .sub { font-weight: 600; color: var(--muted); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#view-vault { align-items: center; justify-content: center; }

/* Main app: vertical sidebar nav + scrollable content */
#view-main { flex: 1; display: flex; min-height: 0; gap: 22px; padding: 22px 24px 28px; }
.sidebar {
  width: 228px; flex-shrink: 0;
  background: linear-gradient(180deg, rgba(255, 250, 242, 0.92), rgba(250, 243, 232, 0.86));
  border: 1px solid rgba(217, 203, 183, 0.9); padding: 18px 12px; display: flex;
  flex-direction: column; gap: 5px; border-radius: 24px; box-shadow: var(--shadow);
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.sidebar-logo img { height: 30px; width: auto; filter: drop-shadow(0 8px 14px rgba(15, 157, 140, 0.16)); }
.sidebar-logo span { font-family: var(--font-display); font-weight: 600; font-size: 16px; letter-spacing: .3px; }
.navbtn {
  position: relative; display: flex; align-items: center; gap: 11px; text-align: left;
  padding: 11px 14px; border-radius: 14px; border: 1px solid transparent;
  background: transparent; color: var(--muted); cursor: pointer; font-size: 14px;
  font-weight: 600; transition: background .15s, color .15s, border-color .15s, transform .15s;
}
.navbtn:hover { background: rgba(15, 157, 140, 0.08); color: var(--text); border-color: rgba(15, 157, 140, 0.12); transform: translateX(2px); }
.navbtn-active {
  background: linear-gradient(90deg, rgba(15, 157, 140, 0.16), rgba(15, 157, 140, 0.02));
  color: var(--text); border-color: rgba(15, 157, 140, 0.18);
}
.navbtn-active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent); box-shadow: 0 0 10px rgba(217, 108, 71, 0.4);
}
.navbtn-active .nav-ico { color: var(--brand); }
.nav-ico { font-size: 14px; width: 18px; text-align: center; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: auto; }

.card {
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.94), rgba(255, 249, 240, 0.88));
  border: 1px solid rgba(217, 203, 183, 0.92);
  border-radius: var(--radius); padding: 22px; margin: 0;
  box-shadow: var(--shadow);
}
.center-card { width: min(440px, calc(100vw - 32px)); text-align: center; display: flex; flex-direction: column; gap: 12px; }
.vault-logo {
  width: min(240px, 70%);
  height: auto;
  margin: 0 auto 6px;
  display: block;
  filter: drop-shadow(0 12px 26px rgba(15, 157, 140, 0.16));
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.eyebrow {
  display: inline-flex; align-items: center; width: fit-content;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .18em;
  color: var(--accent);
}

.page-head {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 2px 2px;
}
.page-head h1 {
  margin: 0;
  max-width: 860px;
  font-family: var(--font-display);
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.02;
  letter-spacing: -.03em;
}
.page-head-compact h1 { font-size: clamp(24px, 3vw, 34px); max-width: 760px; }
.page-copy { max-width: 760px; font-size: 15px; line-height: 1.6; }
.feature-grid { align-items: start; }
.card-form h3, .card-list h3 { margin-bottom: 6px; }

h2, h3 { margin: 0 0 12px; font-family: var(--font-display); font-weight: 600; letter-spacing: .2px; }
h2 { font-size: 30px; }
h3 { font-size: 17px; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; }

input, button { font: inherit; }
input {
  width: 100%; padding: 12px 14px; margin: 6px 0;
  background: rgba(255, 255, 255, 0.88); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text); transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder { color: #8f8a82; }
input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-glow); background: #fff; }
/* Checkboxes/radios must NOT inherit the full-width text-input styling. */
input[type="checkbox"], input[type="radio"] {
  width: 16px; height: 16px; flex: none; margin: 0; padding: 0;
  accent-color: var(--brand); cursor: pointer;
}

.btn {
  padding: 11px 16px; border-radius: 12px; border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.6); color: var(--text); cursor: pointer; font-weight: 600;
  transition: border-color .15s, background .15s, box-shadow .15s, transform .05s;
}
.btn:hover { border-color: var(--brand-2); background: var(--panel-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--border); background: var(--panel-2); }
.btn-primary {
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  border-color: transparent; color: var(--on-primary); font-weight: 700;
  box-shadow: 0 6px 18px -6px var(--brand-glow);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--primary-hover), var(--brand)); box-shadow: 0 8px 22px -6px var(--brand-glow); }
.btn-primary:disabled:hover { background: linear-gradient(180deg, var(--brand), var(--brand-2)); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.62); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: rgba(255, 107, 107, 0.08); }

.pill { font-size: 11px; font-weight: 600; padding: 4px 11px; border-radius: 999px; letter-spacing: .3px; }
.pill-locked { background: rgba(198, 83, 83, 0.12); color: #9f3f3f; border: 1px solid rgba(198, 83, 83, 0.22); }
.pill-unlocked { background: rgba(35, 139, 97, 0.12); color: #1e6d4d; border: 1px solid rgba(35, 139, 97, 0.22); }
.pill-profile { background: var(--brand-glow); color: var(--brand-deep); border: 1px solid rgba(15, 157, 140, 0.22); }
.pill-profile b { color: var(--text); }

/* Footer */
.appfooter {
  flex-shrink: 0; padding: 14px 22px; text-align: center;
  font-size: 12px; color: var(--muted);
  border-top: 1px solid rgba(217, 203, 183, 0.72);
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.35));
}
.appfooter .brand-mini { color: var(--brand); font-weight: 600; }

.tabpane { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 20px; width: min(1280px, 100%); margin: 0 auto; }

.toolbar { display: flex; align-items: center; gap: 14px; padding: 0; flex-wrap: wrap; }
.toolbar-surface {
  padding: 16px 18px; border: 1px solid rgba(217, 203, 183, 0.92); border-radius: 18px;
  background: rgba(255, 252, 246, 0.9); box-shadow: var(--shadow);
}
/* Only the direct-child search box is 260px — NOT the nested filter checkboxes. */
.toolbar > input { width: 260px; margin: 0; }
.chk {
  font-size: 13px; color: var(--muted); display: inline-flex; align-items: center;
  gap: 6px; white-space: nowrap; cursor: pointer;
}
.filter-group {
  display: inline-flex; align-items: center; gap: 14px; padding: 7px 14px;
  border: 1px solid var(--border); border-radius: 12px; background: rgba(255, 255, 255, 0.65);
}
.filter-label { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.chk-toggle { padding: 7px 12px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255, 255, 255, 0.65); }
.seg { display: flex; }
.seg-btn { padding: 8px 14px; border: 1px solid var(--border); background: rgba(255, 255, 255, 0.7);
  color: var(--muted); cursor: pointer; }
.seg-btn:first-child { border-radius: 10px 0 0 10px; }
.seg-btn:last-child { border-radius: 0 10px 10px 0; }
.seg-active {
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  color: var(--on-primary); border-color: transparent; font-weight: 600;
}

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.data-table th { color: var(--muted); cursor: pointer; user-select: none; position: sticky; top: 0;
  background: #fbf5eb; }
.data-table tr:hover td { background: #f6efe4; }
.data-table .clickable-row { cursor: pointer; }
.data-table .row-open > td { background: #edf4f0; border-bottom-color: transparent; }
.data-table .detail-row > td { background: #f8f1e5; padding: 0; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 5px; background: var(--panel-2); }
.badge-user { color: var(--user); } .badge-group { color: var(--group); }

/* -------- Relationship flowchart (expanded table row) -------- */
.flow { display: flex; align-items: flex-start; gap: 22px; padding: 16px 14px; }
.flow-root {
  flex-shrink: 0; border: 1px solid var(--border); border-left-width: 4px;
  border-radius: 9px; padding: 10px 14px; background: var(--panel); min-width: 190px;
}
.flow-root .fb-type { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.flow-root .fb-name { font-size: 15px; font-weight: 700; margin: 2px 0; }
.flow-root .fb-sub { font-size: 11px; color: var(--muted); }
.flow-root .fb-sub.mono { font-family: ui-monospace, monospace; word-break: break-all; }

.flow-cats { display: flex; flex-direction: column; gap: 12px; position: relative; padding-left: 22px; }
.flow-cats::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 1px; background: var(--border);
}
.flow-cat { display: flex; align-items: flex-start; gap: 14px; position: relative; }
.flow-cat::before {
  content: ""; position: absolute; left: -22px; top: 14px; width: 22px; height: 1px; background: var(--border);
}
.flow-cat-label { min-width: 168px; padding-top: 6px; font-size: 12px; color: var(--muted); }
.flow-cat-n { color: var(--text); background: var(--panel-2); border-radius: 999px; padding: 0 7px; font-size: 11px; margin-left: 4px; }
.flow-items { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }

.flow-boxwrap { display: flex; flex-direction: column; gap: 6px; }
.flow-nested {
  margin-top: 6px; padding: 8px 10px; border: 1px dashed var(--border);
  border-radius: 8px; background: rgba(255, 255, 255, 0.55);
}
.flow-nested .flow { padding: 4px 2px; flex-wrap: wrap; gap: 16px; }
.flow-nested .flow-root { min-width: 160px; }
.flow-box {
  border: 1px solid var(--border); border-left-width: 3px; border-radius: 7px;
  padding: 6px 11px; background: rgba(255, 255, 255, 0.75); font-size: 12px; max-width: 340px;
  word-break: break-word;
}
.flow-box.expandable { cursor: pointer; }
.flow-box.expandable::after { content: " ▸"; color: var(--muted); }
.flow-box.expandable.open::after { content: " ▾"; color: var(--text); }
.flow-doc {
  background: #fffdf8; border: 1px solid var(--border); border-radius: 7px;
  padding: 10px; font-size: 11.5px; line-height: 1.45; max-height: 340px; overflow: auto;
  white-space: pre-wrap; word-break: break-word; margin: 0; max-width: 520px;
}
.flow-color-account { border-left-color: var(--account); }
.flow-color-user { border-left-color: var(--user); }
.flow-color-group { border-left-color: var(--group); }
.flow-color-role { border-left-color: var(--role); }
.flow-color-managed { border-left-color: var(--managed); }
.flow-color-managed_policy { border-left-color: var(--managed); }
.flow-color-custom { border-left-color: #60a5fa; }
.flow-color-inline { border-left-color: var(--inline); }
.flow-color-inline_policy { border-left-color: var(--inline); }
.flow-color-trust { border-left-color: #f59e0b; }
.flow-color-cross { border-left-color: var(--danger); }
.flow-color-idc_user { border-left-color: #5eead4; }
.flow-color-idc_group { border-left-color: #c4b5fd; }
.flow-color-permission_set { border-left-color: #e879f9; }
.badge-role { color: var(--role); }

.scroll { overflow: auto; flex: 1; }

.progress-wrap { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.progress { flex: 1; height: 8px; background: #eadfce; border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--primary); transition: width .3s; }

.graph-layout { flex: 1; position: relative; min-height: 0; }
#graph-svg { width: 100%; height: 100%; display: block;
  background: radial-gradient(circle at 50% 30%, #f6efe4, #efe4d3); border-radius: 22px; border: 1px solid rgba(217, 203, 183, 0.92); box-shadow: var(--shadow); }
.detail {
  position: absolute; top: 12px; right: 12px; width: 380px; max-height: calc(100% - 24px);
  overflow: auto; background: rgba(255, 252, 246, 0.96); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px; box-shadow: var(--shadow);
}
.detail-close { position: absolute; top: 8px; right: 8px; font-size: 18px; line-height: 1; padding: 2px 8px; }
.detail pre { background: rgba(255, 255, 255, 0.78); padding: 10px; border-radius: 7px; overflow: auto;
  font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.detail h4 { margin: 14px 0 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; }

.node { cursor: pointer; stroke: #f9f5ee; stroke-width: 1.5px; }
.node.dim { opacity: 0.15; }
.node.hit { stroke: #ffffff; stroke-width: 2.5px; }
.link { stroke: #8d867d; stroke-opacity: 0.55; }
.link.trusts { stroke: #f59e0b; stroke-opacity: 0.9; }
.link.cross { stroke: #ef4444; stroke-opacity: 0.95; stroke-width: 2px; }
.link.dim { stroke-opacity: 0.05; }
.nodelabel { fill: #203034; font-size: 10px; pointer-events: none; }
.nodelabel.dim { opacity: 0.1; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: rgba(255, 250, 242, 0.96); border: 1px solid var(--brand-2); color: var(--text);
  padding: 11px 18px; border-radius: 10px; z-index: 50; font-size: 13px;
  box-shadow: 0 12px 30px -10px rgba(69, 54, 32, 0.22), 0 0 0 3px var(--brand-glow);
}
.legend { position: absolute; bottom: 12px; left: 12px; font-size: 11px; color: var(--muted);
  background: rgba(255, 252, 246, 0.9); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px; }
.legend span { display: flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.target-group { margin: 10px 0; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255, 255, 255, 0.56); }
.target-group > h4 { margin: 0 0 8px; font-size: 14px; }
.row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }

/* SSO account + role selection */
.acct-block { border-top: 1px solid var(--border); padding: 8px 0; }
.acct-block:first-of-type { border-top: none; }
.acct-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.acct-head .acct-name { font-weight: 600; }
.acct-head .acct-id { color: var(--muted); font-size: 12px; font-family: ui-monospace, monospace; }
.acct-head .acct-count { color: var(--muted); font-size: 12px; margin-left: auto; }
.role-list { display: flex; flex-direction: column; gap: 2px; padding-left: 6px; }
.role-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; }
.role-row:hover { background: rgba(15, 157, 140, 0.07); }
.role-row .role-name { font-family: ui-monospace, monospace; font-size: 12px; }

/* Auth success banner */
.auth-ok {
  display: flex; flex-direction: column; gap: 4px; margin: 8px 0 12px;
  padding: 12px 14px; border: 1px solid rgba(35, 139, 97, 0.28); background: rgba(35, 139, 97, 0.08);
  border-radius: 14px; font-size: 13px;
}
.auth-ok .auth-ok-head { color: #1e6d4d; font-weight: 700; }
.auth-ok .kv { color: var(--muted); }
.auth-ok .kv b { color: var(--text); font-weight: 500; font-family: ui-monospace, monospace; }
.auth-ok code { color: var(--text); font-family: ui-monospace, monospace; word-break: break-all; }

/* -------- Permissions report -------- */
.perm-row {
  display: grid; grid-template-columns: 70px 1fr 130px auto; align-items: center; gap: 12px;
  padding: 11px 14px; border: 1px solid var(--border); border-radius: 9px;
  background: rgba(255, 255, 255, 0.72); margin-bottom: 8px; cursor: pointer; transition: border-color .15s;
}
.perm-row:hover { border-color: var(--brand-2); }
.perm-row.open { border-color: var(--brand); background: #eef7f3; }
.perm-type { font-size: 11px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted);
  border-left: 3px solid var(--border); padding-left: 8px; }
.perm-name { font-weight: 600; }
.perm-acct { color: var(--muted); font-size: 12px; font-family: var(--font-mono); }
.perm-summary { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.oc { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.oc-full { background: rgba(52,211,153,.16); color: #6ee7b7; }
.oc-partial { background: var(--brand-glow); color: #117769; }
.oc-cond { background: rgba(217,108,71,.14); color: #b95a3a; }
.oc-denied { background: rgba(198,83,83,.14); color: #9f3f3f; }

.perm-detail {
  border: 1px solid var(--brand-2); border-radius: 10px; padding: 16px;
  background: #fff9f1; margin: -2px 0 12px;
}
.pipeline { display: flex; align-items: stretch; flex-wrap: wrap; gap: 8px; }
.pipe-arrow { display: flex; align-items: center; color: var(--muted); font-size: 18px; }
.pipe-stage {
  flex: 1; min-width: 150px; border: 1px solid var(--border); border-top: 3px solid var(--border);
  border-radius: 8px; padding: 9px 11px; background: rgba(255, 255, 255, 0.72);
}
.pipe-stage.inactive { opacity: .55; }
.pipe-stage.stage-identity.active { border-top-color: var(--user); }
.pipe-stage.stage-boundary.active { border-top-color: var(--inline); }
.pipe-stage.stage-scp.active { border-top-color: var(--managed); }
.pipe-stage.stage-rcp.active { border-top-color: var(--accent); }
.pipe-stage.stage-net { border-top-color: var(--brand); }
.pipe-title { font-size: 11px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); margin-bottom: 5px; }
.pipe-body { font-size: 12.5px; word-break: break-word; display: flex; flex-wrap: wrap; gap: 5px; }
.perm-arn { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin: 10px 0 4px; word-break: break-all; }

.svc-head { margin: 12px 0 8px; font-size: 12px; }
.svc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.svc-chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 4px 10px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--border); background: rgba(255, 255, 255, 0.72); color: var(--text);
  font-family: var(--font-mono); transition: border-color .12s, background .12s;
}
.svc-chip:hover { border-color: var(--brand-2); }
.svc-chip.sel { border-color: var(--brand); background: #f1faf8; box-shadow: 0 0 0 2px var(--brand-glow); }
.svc-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.svc-chip.oc-full .svc-dot { color: #6ee7b7; }
.svc-chip.oc-partial .svc-dot { color: #7fe9dd; }
.svc-chip.oc-cond .svc-dot { color: #b7adff; }
.svc-chip.oc-denied .svc-dot { color: #ff9a9a; }
.svc-cname { color: var(--text); }
.svc-cflag { color: var(--accent); font-weight: 700; }
.svc-by { font-size: 11px; color: var(--muted); }

.svc-drill {
  margin-top: 10px; border: 1px solid var(--border); border-radius: 9px;
  padding: 12px 14px; background: rgba(255, 255, 255, 0.64);
}
.drill-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.svc-name { font-family: var(--font-mono); font-size: 13px; font-weight: 700; }
.drill-note { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.drill-cols { display: flex; gap: 24px; flex-wrap: wrap; }
.drill-col { min-width: 220px; flex: 1; }
.drill-col h5 { margin: 4px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); font-family: var(--font); }
.drill-n { background: var(--panel-2); color: var(--text); border-radius: 999px; padding: 0 7px; font-size: 10px; margin-left: 4px; }
.drill-col ul { margin: 0; padding: 0; list-style: none; max-height: 260px; overflow: auto; display: flex; flex-direction: column; gap: 3px; }
.drill-col li { font-family: var(--font-mono); font-size: 12px; color: #27514e; padding: 3px 8px; background: rgba(255, 255, 255, 0.76); border: 1px solid var(--border-soft); border-radius: 6px; }
.drill-deny h5 { color: #9f3f3f; }
.drill-deny .drill-n { background: rgba(198,83,83,.14); color: #9f3f3f; }
.drill-deny li { color: #9f3f3f; background: rgba(198,83,83,.08); border-color: rgba(198,83,83,.18); }

/* -------- Escalation report -------- */
.esc-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 14px; background: rgba(255, 255, 255, 0.76);
  margin-bottom: 10px; cursor: pointer; transition: border-color .15s, background .15s;
}
.esc-row:hover { border-color: var(--brand-2); }
.esc-row.open { border-color: var(--accent); background: #fff6ed; }
.esc-main { flex: 1; min-width: 0; }
.esc-titleline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 5px; }
.esc-title { font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.esc-meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; font-family: var(--font-mono); }
.esc-summary { font-size: 13px; line-height: 1.5; }
.sev-pill {
  display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 9px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
}
.sev-critical { background: rgba(198,83,83,.18); color: #8f2f2f; }
.sev-high { background: rgba(217,108,71,.18); color: #a44d30; }
.sev-medium { background: rgba(15,157,140,.16); color: #0d6d62; }
.sev-low { background: rgba(111,123,120,.14); color: #4e5956; }
.esc-detail {
  margin: -2px 0 12px; border: 1px solid rgba(217,108,71,.28); border-radius: 14px;
  padding: 16px; background: #fffdf8;
}
.esc-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.esc-tag {
  font-size: 11px; padding: 3px 8px; border-radius: 999px; background: rgba(15,157,140,.12);
  color: var(--brand-deep); border: 1px solid rgba(15,157,140,.16);
}
.esc-sec { margin-bottom: 14px; }
.esc-sec:last-child { margin-bottom: 0; }
.esc-sec h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.esc-sec p, .esc-sec li { font-size: 13px; line-height: 1.55; }
.esc-sec ol, .esc-sec ul { margin: 0; padding-left: 18px; }
.esc-notes {
  margin-top: 14px; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.62);
}
.esc-notes h4 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.esc-notes ul { margin: 0; padding-left: 18px; }

/* -------- Guardrails: OU tree + SCP/RCP policies -------- */
.gr-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 1000px) { .gr-layout { grid-template-columns: 1fr; } }

#gr-tree { font-size: 13px; }
.tnode-row {
  display: flex; align-items: center; gap: 7px; padding: 4px 6px; border-radius: 7px;
  border: 1px solid transparent; flex-wrap: wrap;
}
.tnode-row:hover { background: var(--panel-2); }
.tnode-row.hit { border-color: var(--brand); background: var(--brand-glow); }
.tkids { margin-left: 18px; border-left: 1px dashed var(--border); padding-left: 8px; }
.tcaret { width: 14px; cursor: pointer; color: var(--muted); user-select: none; text-align: center; }
.tcaret-empty { cursor: default; }
.tglyph { width: 16px; text-align: center; }
.t-root > .tglyph { color: var(--account); }
.t-organizational_unit > .tglyph { color: var(--accent); }
.t-account > .tglyph { color: var(--user); }
.tname { font-weight: 500; }
.tid { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.tchips { display: inline-flex; gap: 5px; flex-wrap: wrap; margin-left: 4px; }

.pchip {
  font-size: 11px; padding: 1px 8px; border-radius: 999px; cursor: pointer;
  border: 1px solid transparent; white-space: nowrap;
}
.pchip-scp { background: rgba(244,114,182,.15); color: #f9a8d4; border-color: rgba(244,114,182,.35); }
.pchip-rcp { background: rgba(139,124,255,.15); color: #c4b5fd; border-color: rgba(139,124,255,.35); }
.pchip.sel { outline: 2px solid var(--brand); }

.gr-prow {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 12px; background: rgba(255, 255, 255, 0.74); margin-bottom: 7px;
}
.gr-prow:hover { border-color: var(--brand-2); }
.gr-prow.open { border-color: var(--brand); background: #eef7f3; }
.pbadge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 5px; }
.pbadge-scp { background: rgba(244,114,182,.16); color: #f9a8d4; }
.pbadge-rcp { background: rgba(139,124,255,.16); color: #c4b5fd; }
.pname { font-weight: 600; flex: 1; min-width: 0; }
.pmanaged { font-size: 10px; color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; }
.ptargets { font-size: 11px; color: var(--muted); }

.gr-pdetail { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
  background: rgba(255, 255, 255, 0.68); margin: -3px 0 10px; }
.pd-sec { margin-bottom: 12px; }
.pd-sec h5 { margin: 0 0 7px; font-size: 11px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); }
.pd-targets { display: flex; flex-wrap: wrap; gap: 6px; }
.pd-target { font-size: 12px; padding: 3px 9px; border-radius: 7px; background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border); }
.pd-target.t-account { font-family: var(--font-mono); }
.pd-doc { background: #fffdf8; border: 1px solid var(--border); border-radius: 8px; padding: 10px;
  font-size: 12px; line-height: 1.5; max-height: 380px; overflow: auto; white-space: pre-wrap;
  word-break: break-word; margin: 0; font-family: var(--font-mono); }

/* -------- Profiles: clickable single-select list -------- */
.profile-list { display: flex; flex-direction: column; gap: 8px; }
.profile-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 14px; background: rgba(255, 255, 255, 0.74);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.profile-item:hover { border-color: var(--primary); }
.profile-item.selected { border-color: var(--primary); background: #eef8f4; }
.profile-radio {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border);
  flex-shrink: 0; position: relative;
}
.profile-item.selected .profile-radio { border-color: var(--primary); }
.profile-item.selected .profile-radio::after {
  content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--primary);
}
.profile-item .pi-main { flex: 1; min-width: 0; }
.profile-item .pi-label { font-weight: 600; }
.profile-item .pi-sub { color: var(--muted); font-size: 12px; }
.profile-item .pi-type {
  font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #f8efe3;
  border: 1px solid var(--border); color: var(--muted);
}
.profile-item .pi-selected-tag { font-size: 11px; color: var(--primary); font-weight: 600; }

/* -------- Scan: structured profile/auth group -------- */
.profile-group { display: flex; flex-direction: column; gap: 10px; }
.pg-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pg-title { display: flex; align-items: baseline; gap: 10px; }
.pg-name { font-size: 20px; font-weight: 700; }
.pg-kind {
  font-size: 11px; padding: 4px 9px; border-radius: 999px; background: #f8efe3;
  border: 1px solid var(--border); color: var(--muted); text-transform: uppercase;
}
.pg-meta { color: var(--muted); font-size: 13px; }
.pg-meta code { font-family: ui-monospace, monospace; color: var(--text); }
.pg-auth:empty { display: none; }
.pg-auth .auth-ok { margin: 0; }

/* -------- Scan: 2-column layout -------- */
.scan-cols { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
.scan-left { max-height: calc(100vh - 320px); overflow: auto; }
.scan-right { position: sticky; top: 14px; }
.btn-block { width: 100%; }
.scan-clear-btn { margin-top: 8px; }
.scan-msg { margin-top: 10px; min-height: 18px; }
.scan-log {
  margin-top: 10px; background: #fffdf8; border: 1px solid var(--border);
  border-radius: 8px; padding: 10px; font-size: 12px; line-height: 1.5;
  font-family: ui-monospace, monospace; color: #48605f; max-height: 320px;
  overflow: auto; white-space: pre-wrap; word-break: break-word;
}
@media (max-width: 900px) { .scan-cols { grid-template-columns: 1fr; } }

@media (max-width: 1100px) {
  #view-main { gap: 18px; padding: 18px; }
  .sidebar { width: 210px; }
}

@media (max-width: 900px) {
  #view-main { flex-direction: column; }
  .sidebar { width: 100%; }
  .tabpane { width: 100%; }
  .page-head h1 { font-size: clamp(26px, 9vw, 36px); }
}

@media (max-width: 760px) {
  .topbar { padding: 14px 16px; }
  #view-main { padding: 14px; }
  .grid-2 { grid-template-columns: 1fr; }
  .toolbar > input { width: 100%; }
  .detail { position: static; width: 100%; max-height: none; margin-top: 14px; }
}
