/* ── Reset & variables (from cis.css) ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #ffffff;
  --bg2:         #f5f5f3;
  --bg3:         #eeede8;
  --border:      rgba(0,0,0,0.10);
  --border2:     rgba(0,0,0,0.18);
  --text:        #1a1a18;
  --text2:       #5f5e5a;
  --text3:       #9c9a92;
  --blue-bg:     #e6f1fb;
  --blue:        #185fa5;
  --blue-dark:   #0c447c;
  --purple-bg:   #eeedfe;
  --purple:      #534ab7;
  --green-bg:    #eaf3de;
  --green:       #3b6d11;
  --red-bg:      #fcebeb;
  --red:         #a32d2d;
  --amber-bg:    #faeeda;
  --amber:       #854f0b;
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --top-h:       52px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:       #1e1e1c;
    --bg2:      #151513;
    --bg3:      #2a2a27;
    --border:   rgba(255,255,255,0.08);
    --border2:  rgba(255,255,255,0.16);
    --text:     #e8e6de;
    --text2:    #9c9a92;
    --text3:    #605e58;
    --blue-bg:  #0c2540;
    --blue:     #85b7eb;
    --blue-dark:#b5d4f4;
    --purple-bg:#1e1a40;
    --purple:   #afa9ec;
    --green-bg: #162610;
    --green:    #97c459;
    --red-bg:   #2a1010;
    --red:      #f09595;
    --amber-bg: #2a1e08;
    --amber:    #ef9f27;
  }
}

/* ── Base ── */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg2);
  min-height: 100vh;
}

/* ════════════════════════════════════════
   LAYOUT
════════════════════════════════════════ */
.dash-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.dash-main {
  padding: 20px 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

/* ════════════════════════════════════════
   TOP BAR
════════════════════════════════════════ */
.top-bar {
  height: var(--top-h);
  background: var(--bg);
  border-bottom: 0.5px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

.top-logo {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.top-pickers {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.top-select {
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg2);
  border: 0.5px solid var(--border2);
  border-radius: var(--radius-md);
  padding: 5px 28px 5px 10px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%239c9a92' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color 0.12s;
}

.top-select:focus   { border-color: var(--blue); }
.top-select:disabled { opacity: 0.4; cursor: not-allowed; }

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.top-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.top-stat-val {
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
}

.top-stat-excl { color: var(--amber); }

.top-stat-label {
  font-size: 10px;
  color: var(--text3);
  margin-top: 1px;
}

.top-stat-divider {
  width: 0.5px;
  height: 28px;
  background: var(--border2);
}

/* ════════════════════════════════════════
   SECTIONS
════════════════════════════════════════ */
.dash-section {
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 14px;
}

/* ════════════════════════════════════════
   HIERARCHY CHART
════════════════════════════════════════ */
.hierarchy-wrap { min-height: 60px; }

.hier-empty {
  font-size: 12px;
  color: var(--text3);
  text-align: center;
  padding: 24px 0;
}

.hier-root {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hier-root-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 0.5px solid var(--border);
}

.hier-vendor-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.hier-version-badge {
  font-size: 11px;
  background: var(--bg2);
  border: 0.5px solid var(--border2);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--text2);
}

.hier-total {
  font-size: 11px;
  color: var(--text3);
  margin-left: auto;
}

.hier-children {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

@media (max-width: 680px) {
  .hier-children { grid-template-columns: 1fr; }
}

.hier-box {
  border: 0.5px solid var(--border2);
  border-radius: var(--radius-md);
  padding: 12px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.15s;
  user-select: none;
}

.hier-box:hover { background: var(--bg2); }

.hier-box.hier-active {
  border: 1.5px solid var(--blue);
  background: var(--blue-bg);
}

.hier-box-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.hier-box-title {
  font-size: 12px;
  font-weight: 500;
  flex: 1;
}

.hier-box-sub {
  font-size: 11px;
  color: var(--text3);
}

.hier-lv-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.lb1      { background: var(--blue-bg);   color: var(--blue-dark); }
.lb2      { background: var(--purple-bg); color: var(--purple); }
.lb-excl  { background: var(--amber-bg);  color: var(--amber); }

.hier-stats {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.hier-stats span {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity 0.1s;
}

.hier-stats span:hover { opacity: 0.75; }

.hs-pass { background: var(--green-bg); color: var(--green); }
.hs-fail { background: var(--red-bg);   color: var(--red); }
.hs-dis  { background: var(--bg3);      color: var(--text2); }

.hier-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.hier-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 10px;
  border: 0.5px solid var(--border2);
  font-size: 10px;
  color: var(--text2);
}

.hier-tag-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.hier-tag-count {
  font-weight: 600;
  color: var(--text);
}

.hier-excl-pill {
  background: var(--amber-bg);
  border-color: transparent;
  color: var(--amber);
}

.hier-inherit-note {
  font-size: 10px;
  color: var(--text3);
  margin-top: 4px;
  font-style: italic;
}

.hier-excl-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 22px;
}

.hier-none-note {
  font-size: 11px;
  color: var(--text3);
  font-style: italic;
}

/* ════════════════════════════════════════
   METRICS
════════════════════════════════════════ */
.metrics-empty, .metrics-placeholder {
  font-size: 12px;
  color: var(--text3);
  text-align: center;
  padding: 20px 0;
}

.metrics-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 20px;
  align-items: center;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 0.5px solid var(--border);
}

@media (max-width: 600px) {
  .metrics-top { grid-template-columns: 1fr 1fr; }
}

/* Ring */
.metric-ring-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}

.metric-ring {
  width: 80px;
  height: 80px;
}

.ring-arc {
  transition: stroke-dashoffset 0.6s cubic-bezier(0.4,0,0.2,1);
}

.metric-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ring-pct {
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
}

.ring-sub {
  font-size: 9px;
  color: var(--text3);
  margin-top: 2px;
}

/* Auto bar */
.metric-auto {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.metric-auto-label {
  font-size: 11px;
  color: var(--text2);
}

.metric-auto-val {
  font-size: 20px;
  font-weight: 600;
  color: var(--blue);
  line-height: 1;
}

.metric-auto-denom {
  font-size: 13px;
  color: var(--text3);
  font-weight: 400;
}

.metric-auto-bar {
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
}

.metric-auto-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* Delta */
.metric-delta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 0.5px solid var(--border2);
  background: var(--bg2);
  min-width: 110px;
  user-select: none;
  transition: background 0.1s;
}

.metric-delta:hover { background: var(--bg3); }

.metric-delta-label {
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-delta-vals {
  display: flex;
  flex-direction: column;
  gap: 3px;
  opacity: 0.3;
  transition: opacity 0.2s;
}

.metric-delta-vals.delta-active { opacity: 1; }

.delta-pass, .delta-fail {
  font-size: 12px;
  font-weight: 500;
  color: var(--text3);
}

.delta-pass.pos { color: var(--green); }
.delta-pass.neg { color: var(--red); }
.delta-fail.pos { color: var(--red); }
.delta-fail.neg { color: var(--green); }

.metric-delta-hint {
  font-size: 10px;
  color: var(--blue);
}

/* Metric rows */
.metrics-rows {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.mrow {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 0 12px;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--border);
}

.mrow:last-child { border-bottom: none; }

.mrow.clickable {
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin: 0 -8px;
  padding: 10px 8px;
  transition: background 0.1s;
}

.mrow.clickable:hover { background: var(--bg2); }

.mrow-label {
  font-size: 12px;
  color: var(--text2);
  grid-column: 1;
  grid-row: 1;
}

.mrow-val {
  font-size: 20px;
  font-weight: 600;
  grid-column: 2;
  grid-row: 1 / 3;
  text-align: right;
}

.mrow-val.fail { color: var(--red); }
.mrow-val.pass { color: var(--green); }
.mrow-val.dis  { color: var(--text3); }

.mrow-sub {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.mrow-sub span {
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
}

.mrow-bar-bg {
  flex: 1;
  height: 3px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
  max-width: 140px;
}

.mrow-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.pass-bar { background: var(--green); }
.fail-bar { background: var(--red); }
.dis-bar  { background: var(--text3); }
.all-bar  { background: var(--blue); }

/* ════════════════════════════════════════
   MAIN TABS ROW
════════════════════════════════════════ */
.main-tabs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.main-tabs-left {
  display: flex;
  gap: 2px;
}

.main-tab-btn {
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  color: var(--text2);
  background: none;
  border: none;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.main-tab-btn:hover { background: var(--bg2); color: var(--text); }

.main-tab-active {
  background: var(--bg2);
  color: var(--text);
}

/* ════════════════════════════════════════
   CONTROL TABLE TABS
════════════════════════════════════════ */
.table-tabs {
  display: flex;
  gap: 2px;
  padding-bottom: 12px;
  border-bottom: 0.5px solid var(--border);
  margin-bottom: 12px;
  overflow-x: auto;
}

.tab-btn {
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  color: var(--text2);
  background: none;
  border: 0.5px solid transparent;
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.tab-btn:hover { background: var(--bg2); color: var(--text); }

.tab-active {
  background: var(--text);
  color: var(--bg);
  border-color: transparent;
}

.tab-count {
  font-size: 10px;
  opacity: 0.65;
}

.tab-active .tab-count { opacity: 0.8; }

.table-empty {
  font-size: 12px;
  color: var(--text3);
  text-align: center;
  padding: 28px 0;
}

/* ════════════════════════════════════════
   CONTROL ROWS
════════════════════════════════════════ */
.ctrl-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ctrl-row {
  border-bottom: 0.5px solid var(--border);
}

.ctrl-row:last-child { border-bottom: none; }

.ctrl-row-open .ctrl-row-head {
  background: var(--bg2);
}

.ctrl-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.1s;
  user-select: none;
}

.ctrl-row-head:hover { background: var(--bg2); }

.ctrl-id {
  font-size: 10px;
  font-weight: 600;
  font-family: 'SF Mono', 'Cascadia Code', monospace;
  color: var(--text3);
  min-width: 100px;
  flex-shrink: 0;
}

.ctrl-lv-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}

.ctrl-title {
  font-size: 12px;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ctrl-meta {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.ctrl-assets, .ctrl-scan {
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
}

.ctrl-status {
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 80px;
  text-align: right;
}

.st-pass        { color: var(--green); }
.st-fail        { color: var(--red); }
.st-dis         { color: var(--text3); }
.st-manual-pass { color: var(--blue); }
.st-manual-rev  { color: var(--amber); }

.ctrl-chevron {
  font-size: 16px;
  color: var(--text3);
  transition: transform 0.2s;
  flex-shrink: 0;
  line-height: 1;
}

.chevron-open { transform: rotate(90deg); }

/* ── Expanded section ── */
.ctrl-expanded {
  padding: 12px 16px 14px;
  border-top: 0.5px solid var(--border);
  background: var(--bg);
}

.exp-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 8px;
}

.asset-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 10px;
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.asset-row-wrap {
  display: flex;
  flex-direction: column;
  border-bottom: 0.5px solid var(--border);
}

.asset-row-wrap:last-child { border-bottom: none; }

.asset-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  transition: background 0.1s;
}

.asset-row.asset-excluded { opacity: 0.5; }

.asset-name {
  font-size: 12px;
  font-family: 'SF Mono', 'Cascadia Code', monospace;
  flex: 1;
}

.asset-status-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
}

.badge-pass     { background: var(--green-bg);  color: var(--green); }
.badge-fail     { background: var(--red-bg);    color: var(--red); }
.badge-excluded { background: var(--amber-bg);  color: var(--amber); }

.action-btn {
  font-size: 11px;
  font-family: inherit;
  font-weight: 500;
  color: var(--blue);
  background: none;
  border: 0.5px solid var(--blue);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  cursor: pointer;
  transition: background 0.1s;
  white-space: nowrap;
}

.action-btn:hover { background: var(--blue-bg); }

.action-undo {
  color: var(--text2);
  border-color: var(--border2);
}

.action-undo:hover { background: var(--bg2); }

.disable-ctrl-btn {
  font-size: 11px;
  font-family: inherit;
  color: var(--red);
  background: none;
  border: 0.5px solid var(--red);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.1s;
  margin-top: 8px;
}

.disable-ctrl-btn:hover { background: var(--red-bg); }

/* Manual form */
.manual-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mf-row { display: flex; flex-direction: column; gap: 4px; }

.mf-label {
  font-size: 11px;
  color: var(--text2);
}

.mf-input {
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 0.5px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  width: 100%;
  resize: vertical;
  outline: none;
  transition: border-color 0.12s;
}

.mf-input:focus { border-color: var(--blue); }

.mf-status {
  font-size: 11px;
  color: var(--text2);
}

/* Disabled info */
.dis-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
  background: var(--bg2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.dis-row {
  display: flex;
  gap: 10px;
  font-size: 12px;
}

.dis-label {
  color: var(--text3);
  min-width: 44px;
  flex-shrink: 0;
}

/* ════════════════════════════════════════
   EXCLUDED ASSETS LIST
════════════════════════════════════════ */
.excl-row {
  padding: 10px 8px;
  border-bottom: 0.5px solid var(--border);
}

.excl-row:last-child { border-bottom: none; }

.excl-row-main {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}

.excl-ctrl-id {
  font-size: 10px;
  font-family: 'SF Mono', 'Cascadia Code', monospace;
  color: var(--text3);
  background: var(--bg2);
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}

.excl-deadline {
  font-size: 11px;
  color: var(--amber);
  flex: 1;
  text-align: right;
}

.excl-reason {
  font-size: 11px;
  color: var(--text3);
  padding-left: 2px;
}

/* ════════════════════════════════════════
   INLINE DRAWER (exclude / disable forms)
════════════════════════════════════════ */
.inline-drawer {
  background: var(--bg2);
  border-top: 0.5px solid var(--border2);
  padding: 10px 12px 12px;
  animation: drawerSlide 0.15s ease;
}

.inline-drawer-ctrl {
  border-top: none;
  border: 0.5px solid var(--border2);
  border-radius: var(--radius-md);
  margin-top: 8px;
}

@keyframes drawerSlide {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.idr-row {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
  align-items: flex-start;
}

.idr-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.idr-field-date {
  flex: 0 0 140px;
}

.idr-label {
  font-size: 11px;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 3px;
}

.idr-input {
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 0.5px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  width: 100%;
  resize: none;
  outline: none;
  transition: border-color 0.12s;
}

.idr-input:focus { border-color: var(--blue); }

.idr-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.idr-submit {
  font-size: 11px;
  font-family: inherit;
  font-weight: 500;
  color: #fff;
  background: var(--blue);
  border: none;
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  cursor: pointer;
  transition: opacity 0.1s;
}

.idr-submit:hover { opacity: 0.88; }

.idr-submit-danger { background: var(--red); }

.idr-cancel {
  font-size: 11px;
  font-family: inherit;
  color: var(--text2);
  background: none;
  border: 0.5px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  cursor: pointer;
  transition: background 0.1s;
}

.idr-cancel:hover { background: var(--bg3); }

.action-btn-active {
  background: var(--blue-bg);
  border-color: var(--blue);
  color: var(--blue-dark);
}

.disable-ctrl-btn-active {
  color: var(--text2);
  border-color: var(--border2);
}

/* ════════════════════════════════════════
   UTILITY
════════════════════════════════════════ */
.hidden { display: none !important; }
