/* =========================================================
   RUNES – Main CSS (compact, dark/light, aligned dashboard)
   ========================================================= */

/* ---------- Tokens (Dark default) ---------- */
:root{
  --bg:#0b0e12;
  --panel:#12151a;
  --panel2:#161c24;
  --border:#202734;
  --txt:#e6ebf3;
  --muted:#98a2b3;
  --link:#8ab4f8;
  --accent:#2bdc85;

  --ok:#15b371; --info:#1e88e5; --warn:#ffd166; --hot:#ff8c42; --crit:#e53935;

  /* RUNES (fixas entre temas) */
  --r-UNRUNED:#c4cbd6;   /* cinza claro */
  --r-VEIL:#15b371;      /* verde */
  --r-ANVIL:#546e7a;     /* ardósia */
  --r-WARD:#1e88e5;      /* AZUL vivo */
  --r-EMBER:#ffd166;     /* âmbar */
  --r-AURUM:#ffbf00;     /* ouro */
  --r-GHOST:#616161;     /* cinza escuro */
  --r-SPARK:#e91e63;     /* magenta */
  --r-FANG:#ff8c42;      /* laranja */
  --r-BLOOD:#e53935;     /* vermelho */

  --radius:12px;
  --gap:12px;
  --fs:12px;
  --lh:1.45;

  /* largura da sidebar (usada no grid e ajustes responsivos) */
  --sidebar-w: 260px;
}

/* ---------- Light theme ---------- */
html[data-theme="light"]{
  --bg:#f6f8fc;
  --panel:#ffffff;
  --panel2:#f3f6fc;
  --border:#dbe3ef;
  --txt:#0f172a;
  --muted:#536176;
  --link:#1a73e8;

  /* mantemos as cores das runas; pequenos ajustes de contraste se quiser: */
  /* (WARD continua azul vivo) */
}

/* ---------- Base ---------- */
*{ box-sizing:border-box }
html,body{ height:100% }
html{ overflow-y:scroll } /* avoid jump */
body{
  margin:0; background:var(--bg); color:var(--txt);
  font:var(--fs)/var(--lh) ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* ---------- Dev environment banner ---------- */
body.dev-env{
  position:relative;
  --env-banner-height:56px;
}

.env-banner{
  position:fixed;
  top:0;
  left:0;
  right:0;
  z-index:9999;
  height:var(--env-banner-height);
  padding:0 22px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:12px;
  color:#fff;
  background:linear-gradient(135deg, rgba(239, 68, 68, .78), rgba(190, 18, 60, .68));
  backdrop-filter:blur(18px) saturate(180%);
  -webkit-backdrop-filter:blur(18px) saturate(180%);
  border-bottom:1px solid rgba(255,255,255,.18);
  box-shadow:0 12px 30px rgba(190,18,60,.32);
}

.env-banner__icon{
  font-size:20px;
  line-height:1;
  filter:drop-shadow(0 6px 14px rgba(0,0,0,.35));
}

.env-banner__text{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:0;
  text-align:center;
}

.env-banner__label{
  pointer-events:none;
  font-size:13px;
  font-weight:750;
  letter-spacing:0.18em;
  text-transform:uppercase;
  text-shadow:0 1px 4px rgba(0,0,0,.45);
}

.env-banner__meta{
  font-size:9px;
  letter-spacing:0.12em;
  color:rgba(255,255,255,.72);
  text-transform:none;
}

.dev-env .env-offset{
  padding-top:var(--env-banner-height);
}

a{ color:var(--link); text-decoration:none }
a:hover{ text-decoration:underline }
.muted{ color:var(--muted) }
.card{
  background:var(--panel); border:1px solid var(--border); border-radius:var(--radius); padding:12px;
}

/* ---------- App layout ---------- */
/* Fallback: Flex coloca sidebar e main lado a lado */
.app{ display:flex; min-height:100vh }
.sidebar{
  display:flex; flex-direction:column;
  flex:0 0 var(--sidebar-w); width:var(--sidebar-w);
  height:100vh; position:sticky; top:0; overflow:auto;
  padding:14px 12px; background:var(--panel); border-right:1px solid var(--border);
}
.brand{ margin-bottom:10px }
.brand-title{ font-size:18px; font-weight:800 }
.brand-sub{ color:var(--muted); font-size:11px }

.theme-pill{
  display:flex; align-items:center; gap:8px;
  padding:8px 10px; width:100%;
  background:var(--panel2); border:1px solid var(--border); color:var(--txt);
  border-radius:10px; cursor:pointer;
  font-size:13px; font-weight:500; letter-spacing:.01em;
  transition:background .2s ease, border-color .2s ease;
}
.theme-pill .icon{ font-size:14px; line-height:1 }
.theme-pill:hover{ background:color-mix(in srgb, var(--panel2) 80%, #ffffff 20%); border-color:color-mix(in srgb, var(--border) 70%, #ffffff 30%); }
.theme-pill:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }

#desktop{ flex:1 1 auto; min-width:0; height:100vh; overflow:auto; padding:12px }

.view{ display:none }
.view.current{ display:block }

/* Preferência: quando o navegador suporta grid, usamos grid sólido */
@supports (display: grid){
  .app{
    display:grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height:100vh;
  }
  .sidebar{
    grid-column: 1;
    width: auto; /* grid controla a largura */
  }
  #desktop{
    grid-column: 2;
    min-width: 0; /* evita overflow horizontal das views */
    height: auto;
  }
}

/* Responsivo: em telas estreitas, empilha e remove deslocamento */
@media (max-width: 860px){
  @supports (display: grid){
    .app{ grid-template-columns: 1fr }
    .sidebar{ height:auto; position:static; width:100% }
    #desktop{ grid-column: 1 }
  }
  /* fallback flex */
  .app{ flex-direction:column }
  .sidebar{
    height:auto; position:static; width:100%;
    border-right:0; border-bottom:1px solid var(--border);
  }
  #desktop{ height:auto }
}

/* Rodapé fixo da sidebar */
.sidebar-foot{
  margin-top:auto;
  padding:12px 0 12px;
  border-top:1px solid var(--border);
  display:flex; flex-direction:column; gap:10px;
  position:sticky; bottom:0;
  background:linear-gradient(180deg, color-mix(in srgb, var(--panel) 82%, #000 18%), var(--panel));
  z-index:5;
  box-shadow:0 -10px 20px rgba(0,0,0,.25);
}
.sidebar-logout{
  display:inline-block;
  padding:8px 10px;
  color:var(--link);
  text-decoration:none;
  font-size:13px;
  font-weight:500;
  letter-spacing:.01em;
}
.sidebar-logout:hover{ text-decoration:underline }

/* ---------- Sidebar items ---------- */
.sidebar .item{
  padding:8px 10px; margin:4px 0; border-radius:8px; cursor:pointer; user-select:none;
}
.sidebar .item:hover{ background:var(--panel2) }
.sidebar .item.active{ background:#1a1f2b; border:1px solid var(--border) }
html[data-theme="light"] .sidebar .item.active{ background:#e7eeff }

/* --- Sidebar: dev items (muted + separated) --- */
.sidebar .item.dev{
  opacity:.62;
  background:var(--panel2);
  font-style:italic;
  border:1px dashed transparent; /* becomes visible on hover/active */
}
.sidebar .item.dev:hover{
  opacity:.9;
  background:color-mix(in srgb, var(--panel2) 85%, #000 15%);
  border-color:var(--border);
}
.sidebar .item.dev.active{
  background:color-mix(in srgb, var(--panel2) 75%, #000 25%);
  border-color:var(--border);
}
/* light theme tweaks for dev items */
html[data-theme="light"] .sidebar .item.dev{
  background:#eef2ff;
}
html[data-theme="light"] .sidebar .item.dev:hover{
  background:#e3e9ff;
}
html[data-theme="light"] .sidebar .item.dev.active{
  background:#d9e2ff;
}
/* Optional visual separator before the first dev item in the list
   (shows a subtle line above any dev item that immediately follows a non-dev) */
.sidebar .item:not(.dev) + .item.dev{ position:relative; }
.sidebar .item:not(.dev) + .item.dev::before{
  content:"";
  position:absolute; left:0; right:0; top:-6px;
  height:1px; background:var(--border);
  opacity:.7;
}

/* ---------- Widgets ---------- */
.widget{
  background:var(--panel); border:1px solid var(--border); border-radius:var(--radius);
  display:flex; flex-direction:column; min-height:140px;
}
.widget.fullscreen{ height:calc(100vh - 24px) }
.w-header{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:10px 12px; border-bottom:1px solid var(--border);
  background:linear-gradient(180deg, rgba(255,255,255,.02), transparent);
}
.w-title{ margin:0; font-size:15px }
.w-actions{ display:flex; align-items:center; gap:8px; flex-wrap:wrap }
.w-body{ padding:10px; overflow:auto }
.w-foot{
  margin-top:auto; border-top:1px solid var(--border); padding:8px 10px;
  display:flex; align-items:center; justify-content:space-between; gap:8px; background:var(--panel);
}

/* ---------- Admin RBAC ---------- */
.admin-view{
  display:flex;
  flex-direction:column;
  gap:20px;
  padding:24px;
}

.admin-head h2{
  margin:0;
  font-size:20px;
}

.admin-head p{
  margin:6px 0 0;
  color:var(--muted);
}

.admin-grid{
  display:grid;
  gap:16px;
  grid-template-columns:repeat(auto-fit,minmax(320px,1fr));
}

.admin-card{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:16px;
  display:flex;
  flex-direction:column;
  gap:12px;
}

.admin-card h3{
  margin:0;
  font-size:16px;
}

.admin-roles{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.admin-card.admin-credentials{
  align-self:start;
}

.admin-card .small{
  font-size:11px;
  margin-top:4px;
}

.cred-info{
  margin:0;
  display:grid;
  grid-template-columns:120px 1fr;
  gap:6px;
  font-size:12px;
}

.cred-info dt{
  font-weight:600;
  color:var(--muted);
}

.cred-info dd{
  margin:0;
  font-weight:700;
}

.cred-form{
  display:flex;
  flex-direction:column;
  gap:8px;
  margin-top:12px;
}

.cred-form input{
  padding:8px 10px;
  border-radius:8px;
  border:1px solid var(--border);
  background:var(--panel2);
  color:var(--txt);
}

.cred-form button{
  margin-top:4px;
  padding:8px 14px;
  align-self:flex-start;
  border-radius:10px;
  border:1px solid var(--border);
  background:linear-gradient(180deg,#f97316,#ea580c);
  color:#2b0a01;
  font-weight:700;
  cursor:pointer;
}

.cred-form .hint{
  margin:0;
  font-size:10px;
  color:var(--muted);
}

.role-pill{
  display:flex;
  gap:14px;
  align-items:flex-start;
  padding:12px;
  border:1px solid var(--border);
  border-radius:12px;
  background:var(--panel2);
}

.role-pill strong{
  font-size:12px;
}

.role-pill p{
  margin:4px 0 0;
  font-size:11px;
  color:var(--muted);
}

.admin-users .toolbar{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.admin-users .toolbar input,
.admin-users .toolbar select{
  height:36px;
  padding:0 12px;
  border-radius:8px;
  border:1px solid var(--border);
  background:var(--panel2);
  color:var(--txt);
}

.admin-users .toolbar button{
  padding:0 14px;
  border-radius:8px;
  border:1px solid var(--border);
  background:linear-gradient(180deg,#818cf8,#6366f1);
  color:#0b0f2b;
  font-weight:700;
  cursor:pointer;
}

#rbacUsers{
  margin-top:12px;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.rbac-user{
  border:1px solid var(--border);
  border-radius:12px;
  padding:12px;
  display:grid;
  gap:8px;
  grid-template-columns:repeat(auto-fit,minmax(180px,1fr));
  align-items:center;
}

.rbac-user strong{
  font-size:12px;
}

.rbac-user select{
  padding:6px 10px;
  border-radius:8px;
  border:1px solid var(--border);
  background:var(--panel2);
  color:var(--txt);
}

.rbac-actions{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
}

.rbac-actions button{
  padding:6px 10px;
  border-radius:8px;
  border:1px solid var(--border);
  background:var(--panel2);
  color:var(--txt);
  cursor:pointer;
}

.rbac-actions button[disabled]{
  opacity:.6;
  cursor:not-allowed;
}

.rbac-password-dialog{
  border:1px solid var(--border);
  border-radius:12px;
  padding:18px 20px;
  background:var(--panel);
  color:var(--txt);
  max-width:360px;
  width:min(360px, 92vw);
}

.rbac-password-dialog::backdrop{
  background:rgba(0,0,0,.45);
  backdrop-filter:blur(4px);
}

.rbac-password-dialog form{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.rbac-password-header h3{
  margin:0;
  font-size:16px;
}

.rbac-password-header p{
  margin:2px 0 0;
  font-size:12px;
  color:var(--muted);
}

.rbac-password-dialog label{
  font-size:11px;
  color:var(--muted);
}

.rbac-password-dialog input{
  border:1px solid var(--border);
  border-radius:8px;
  padding:8px 10px;
  background:var(--panel2);
  color:var(--txt);
}

.rbac-password-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
}

.rbac-password-actions button{
  padding:6px 14px;
  border-radius:8px;
  border:1px solid var(--border);
  background:var(--panel2);
  color:var(--txt);
  cursor:pointer;
}

.rbac-password-actions button[type="submit"]{
  background:linear-gradient(180deg,#2bdc85,#1bbf71);
  color:#032514;
  border-color:rgba(0,0,0,.1);
}

.rbac-perms{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

.rbac-perms label{
  display:flex;
  align-items:center;
  gap:6px;
  padding:6px 10px;
  border:1px solid var(--border);
  border-radius:8px;
  background:var(--panel2);
  font-size:11px;
}

.admin-foot{
  display:flex;
  justify-content:space-between;
  align-items:center;
  flex-wrap:wrap;
  gap:10px;
}

.admin-foot .btn{
  padding:8px 18px;
  border-radius:10px;
  border:1px solid var(--border);
  background:linear-gradient(180deg,#22d3ee,#0ea5e9);
  color:#042f2e;
  font-weight:700;
  cursor:pointer;
}

#rbacStatus{
  min-height:18px;
  font-size:11px;
  color:var(--muted);
}

/* ---------- Settings ---------- */
.settings-view{
  display:flex;
  flex-direction:column;
  gap:20px;
  padding:24px;
}

.settings-head h2{
  margin:0;
  font-size:20px;
}

.settings-head p{
  margin:6px 0 0;
  color:var(--muted);
}


.settings-grid{
  display:grid;
  gap:16px;
  grid-template-columns:repeat(auto-fit, minmax(260px, min(32vw, 380px)));
  align-items:start;
  justify-content:start;
  justify-items:stretch;
}

.settings-card{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:12px;
  display:flex;
  flex-direction:column;
  gap:10px;
  width:100%;
  max-width:100%;
  justify-self:stretch;
}

@media (max-width: 860px){
  .settings-grid{
    grid-template-columns:minmax(0, 1fr);
    justify-content:stretch;
    justify-items:stretch;
  }

  .settings-card{
    max-width:none;
    justify-self:stretch;
  }
}

.settings-card h3{
  margin:0;
  font-size:16px;
}

.settings-theme{
  display:flex;
  gap:14px;
  align-items:center;
}

.settings-theme .theme-option{
  display:flex;
  align-items:center;
  gap:6px;
  font:12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.settings-sidebar-list{
  display:flex;
  flex-direction:column;
  gap:8px;
  align-items:flex-start;
}

.settings-sidebar-item{
  position:relative;
  display:flex;
  align-items:center;
  gap:12px;
  padding:8px 12px;
  border:1px solid var(--border);
  border-radius:10px;
  background:var(--panel2);
  cursor:grab;
  width:fit-content;
  max-width:100%;
}

.settings-sidebar-item span{
  font-weight:600;
  flex:0 1 auto;
}

.settings-sidebar-item.dragging{
  opacity:.45;
}

.settings-sidebar-item::before{
  content:"";
  position:absolute;
  left:8px; right:8px;
  height:0;
  border-radius:999px;
  transition:all .12s ease;
}

.settings-sidebar-item.drop-before::before{
  top:-6px;
  height:3px;
  background:var(--link);
}

.settings-sidebar-item.drop-after::before{
  bottom:-6px;
  height:3px;
  background:var(--link);
}

.settings-sidebar-handle{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:20px;
  font-size:12px;
  color:var(--muted);
  cursor:grab;
  user-select:none;
}

.settings-sidebar-item:focus-within,
.settings-sidebar-item:hover{
  border-color:var(--link);
}

.settings-actions{
  display:flex;
  justify-content:flex-end;
}

.settings-actions button{
  border:0;
  background:var(--link);
  color:#041813;
  font-weight:700;
  padding:8px 14px;
  border-radius:10px;
  cursor:pointer;
}

.settings-default-view{
  display:flex;
  flex-direction:column;
  gap:6px;
  font:12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.settings-default-view__label{
  color:var(--muted);
}

.settings-default-view select{
  padding:6px 10px;
  border-radius:8px;
  border:1px solid var(--border);
  background:var(--panel2);
  color:var(--txt);
  cursor:pointer;
  width:fit-content;
  max-width:100%;
}

.settings-foot{
  display:flex;
  align-items:center;
  justify-content:space-between;
}

.settings-status{
  font-size:11px;
  color:var(--muted);
}

/* ---------- Inputs / Buttons ---------- */
.inp{
  background:var(--panel2); border:1px solid var(--border); color:var(--txt);
  padding:8px 10px; border-radius:10px; outline:none;
}
.inp:focus{ box-shadow:0 0 0 2px rgba(138,180,248,.25) }
.btn{
  padding:8px 12px; border-radius:10px; cursor:pointer; border:1px solid var(--border);
  background:linear-gradient(180deg,#2bdc85,#1bbf71); color:#052814; font-weight:700;
}

/* =========================================================
   FLOWS (table + tint by rune)
   ========================================================= */
.flows-wrap{
  border:1px solid var(--border); border-radius:12px; overflow:auto; background:var(--panel);
  height:calc(100vh - 190px);
}
.flows-table{
  width:100%;
  border-collapse:collapse;
  table-layout:auto;      /* necessário para resize via <colgroup> */
  font-size:11px; line-height:1.35;
}
.flows-table thead th,
.flows-table tbody td{
  padding:6px 8px;
  border-bottom:1px solid var(--border);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.flows-table thead .h th{
  position:sticky; top:0; z-index:3; background:#12131b;
}
html[data-theme="light"] .flows-table thead .h th{ background:#eef2ff }
.flows-table thead .filters th{
  position:sticky; top:32px; z-index:2; background:var(--panel); border-bottom:1px solid var(--border);
}

/* zebra + soft tint by rune */
.flows-table tbody tr:nth-child(2n){ filter:brightness(1.02) }
.flows-table tbody tr td{ color:var(--txt) }
.flows-table tbody tr.r-UNRUNED{ background:color-mix(in srgb, var(--r-UNRUNED) 12%, transparent) }
.flows-table tbody tr.r-VEIL   { background:color-mix(in srgb, var(--r-VEIL) 12%, transparent) }
.flows-table tbody tr.r-ANVIL  { background:color-mix(in srgb, var(--r-ANVIL) 14%, transparent) }
.flows-table tbody tr.r-WARD   { background:color-mix(in srgb, var(--r-WARD) 14%, transparent) } /* mais visível */
.flows-table tbody tr.r-EMBER  { background:color-mix(in srgb, var(--r-EMBER) 14%, transparent) }
.flows-table tbody tr.r-AURUM  { background:color-mix(in srgb, var(--r-AURUM) 14%, transparent) }
.flows-table tbody tr.r-GHOST  { background:color-mix(in srgb, var(--r-GHOST) 12%, transparent) }
.flows-table tbody tr.r-SPARK  { background:color-mix(in srgb, var(--r-SPARK) 12%, transparent) }
.flows-table tbody tr.r-FANG   { background:color-mix(in srgb, var(--r-FANG) 12%, transparent) }
.flows-table tbody tr.r-BLOOD  { background:color-mix(in srgb, var(--r-BLOOD) 12%, transparent) }

/* rune chip – usado em Flows e no Dashboard (mesma aparência!) */
.badge-rune{
  display:inline-flex; align-items:center; gap:6px;
  padding:4px 10px; border-radius:999px; border:1px solid rgba(0,0,0,.18);
  font-weight:800; font-size:11px; color:#000; background:#cfd8dc;
}
.badge-rune .sym{ font-weight:900 }
.badge-rune .count{
  margin-left:6px; padding:0 6px; border-radius:8px;
  background:rgba(255,255,255,.28); font-weight:800;
}
.badge-rune.UNRUNED{ background:var(--r-UNRUNED); color:#111 }
.badge-rune.VEIL{ background:var(--r-VEIL); color:#031a0e }
.badge-rune.ANVIL{ background:var(--r-ANVIL); color:#fff }
.badge-rune.WARD{ background:var(--r-WARD); color:#fff }
.badge-rune.EMBER{ background:var(--r-EMBER); color:#2a1c00 }
.badge-rune.AURUM{ background:var(--r-AURUM); color:#2a1c00 }
.badge-rune.GHOST{ background:var(--r-GHOST); color:#fff }
.badge-rune.SPARK{ background:var(--r-SPARK); color:#fff }
.badge-rune.FANG{ background:var(--r-FANG); color:#2a1200 }
.badge-rune.BLOOD{ background:var(--r-BLOOD); color:#fff }

/* counters row atop flows */
.rune-counters{ display:flex; flex-wrap:wrap; gap:8px; padding:6px 2px 10px 2px; margin-bottom:6px }
.rune-counters .count{ font-weight:800; opacity:.85 }

/* --- column resize handles (único bloco) --- */
.flows-table thead .h th{ position:relative; user-select:none }
.th-resizer{
  position:absolute; top:0; right:0; width:6px; height:100%;
  cursor:col-resize; background:transparent; transition:background .15s;
}
.th-resizer:hover{ background:rgba(138,180,248,.25) }
body.col-resizing{ cursor:col-resize }

/* =========================================================
   ENFORCEMENT FLOW (diagram)
   ========================================================= */
.enf .enf-hero h4{ margin:0 0 6px 0; font-size:15px }
.enf .enf-hero p{ margin:0 }

.enf .enf-grid{ display:grid; grid-template-columns:1fr 320px; gap:var(--gap); margin-top:10px; min-height:calc(100vh - 240px) }
@media (max-width:1100px){ .enf .enf-grid{ grid-template-columns:1fr; min-height:auto } }

.enf .lane, .enf .side{
  background:var(--panel); border:1px solid var(--border); border-radius:var(--radius); padding:12px;
}
.enf .lane-title{ margin:0 0 8px 0; font-size:12px; text-transform:uppercase; letter-spacing:.06em; color:var(--muted) }

.enf .flow{ display:grid; grid-template-columns:1fr auto 1fr auto 1fr auto 1fr; gap:12px; align-items:stretch }
@media (max-width:1100px){ .enf .flow{ grid-template-columns:1fr } .enf .arrow{ text-align:center } }

.enf .node{
  background:var(--panel2); border:1px solid var(--border); border-radius:14px; padding:12px;
  box-shadow:0 1px 0 rgba(255,255,255,.02),0 8px 24px rgba(0,0,0,.12);
}
.enf .node-title{ font-weight:800; margin-bottom:6px }
.enf .node-list{ margin:0; padding-left:16px; color:var(--muted) }
.enf .node-list li{ margin:2px 0 }
.enf .arrow{ align-self:center; color:var(--muted); font-weight:900; padding:0 6px }

.enf .chips{ display:flex; gap:8px; flex-wrap:wrap; margin:6px 0 }
.enf .chip{ background:var(--panel); border:1px solid var(--border); color:var(--txt); padding:4px 8px; border-radius:999px; font-size:11px }
.enf .fine{ font-size:11px }

.enf .side{ display:flex; flex-direction:column; gap:12px }
.enf .side-card{ background:var(--panel2); border:1px solid var(--border); border-radius:14px; padding:12px }
.enf .side-arrow{ text-align:center; color:var(--muted); font-weight:900 }

/* light polish */
html[data-theme="light"] .enf .lane,
html[data-theme="light"] .enf .side,
html[data-theme="light"] .enf .enf-hero{ background:#fff }
html[data-theme="light"] .enf .node,
html[data-theme="light"] .enf .side-card{
  background:#fff; border-color:var(--border); box-shadow:0 1px 0 rgba(0,0,0,.03), 0 8px 18px rgba(0,0,0,.06);
}
html[data-theme="light"] .enf .chip{ background:#f8fbff; border-color:var(--border); color:#0f172a }

/* =========================================================
   DASHBOARD (KPIs + Runes chips)
   ========================================================= */
.kpi-row-7{
  display:grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); gap:12px;
}
@media (max-width:1400px){ .kpi-row-7{ grid-template-columns: repeat(4, 1fr) } }
@media (max-width:900px){  .kpi-row-7{ grid-template-columns: repeat(2, 1fr) } }

.kpi{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:10px;
  padding:12px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  text-align:center;
  box-shadow:0 2px 4px rgba(0,0,0,.05);
}
.kpi-title{
  font-size:11px;
  color:var(--muted);
  margin-bottom:4px;
  text-align:center;
}
.kpi-val{
  font-size:24px;
  font-weight:800;
  text-align:center;
}
html[data-theme="light"] .kpi{ background:#fff; border:1px solid #e6e8eb }

/* chips em linha (usam .badge-rune acima) */
.runes-chips{
  display:flex; flex-wrap:wrap; gap:10px; margin-top:8px;
}

/* --- Runes as rows (dashboard) --- */
.runes-list{ margin-top:8px; }

.runes-aggregate{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:14px;
  overflow:hidden;
}

.runes-table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
}

.runes-table tr{
  cursor:pointer;
  transition:background .12s ease;
}

.runes-table tr:hover{
  background:var(--panel2);
}

.runes-table tr:focus-visible{
  outline:2px solid var(--link);
  outline-offset:-2px;
}

.runes-table td{
  padding:12px;
  border-bottom:1px solid var(--border);
  vertical-align:middle;
}

.runes-table tr:last-child td{ border-bottom:0; }

.runes-table .rune-cell{
  display:flex;
  align-items:center;
  gap:12px;
  min-width:0;
}

.runes-table .rune-desc{
  color:var(--muted);
  font-size:11px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.runes-table .rune-count{
  text-align:right;
  font-weight:800;
  white-space:nowrap;
  width:1%;
}

/* Light theme polish */
html[data-theme="light"] .runes-aggregate{
  background:#fff;
  border-color:var(--border);
  box-shadow:0 1px 0 rgba(0,0,0,.03), 0 8px 18px rgba(0,0,0,.04);
}

html[data-theme="light"] .runes-table tr:hover{
  background:#f3f6fc;
}

/* ========== Enforcement: compactar Data Plane sem afetar o resto ========== */
.enf .enf-grid{ gap:10px; }
.enf .lane{ padding:10px; }
.enf .flow{ grid-template-columns: 1fr 20px 1fr 20px 1fr 20px 1fr; gap:8px; }
.enf .node{ padding:10px; border-radius:12px; }
.enf .node-title{ margin-bottom:4px; }
.enf .node-list{ padding-left:16px; }
.enf .node-list li{ margin:1px 0; }
.enf .arrow{ align-self:center; text-align:center; font-weight:900; color:var(--muted); padding:0; line-height:1; }
.enf .side-card{ padding:10px; border-radius:12px; }
html[data-theme="light"] .enf .lane,
html[data-theme="light"] .enf .side,
html[data-theme="light"] .enf .enf-hero{ background:#fff }
html[data-theme="light"] .enf .node,
html[data-theme="light"] .enf .side-card{
  background:#fff; border-color:var(--border);
  box-shadow:0 1px 0 rgba(0,0,0,.03), 0 8px 18px rgba(0,0,0,.06);
}
/* compact pass + micro anims */
.enf .enf-grid{ min-height:auto !important; gap:10px; }
.enf .lane{ padding:8px 10px; height:auto; }
.enf .flow{ grid-template-columns: 1fr 14px 1fr 14px 1fr 14px 1fr; gap:8px; }
.enf .arrow{ width:14px; text-align:center; line-height:1; padding:0; }
.enf .node{ padding:8px 10px; border-radius:12px; transition:transform .18s ease, box-shadow .18s ease; }
.enf .node-title{ margin-bottom:4px; }
.enf .node-list li{ margin:1px 0; }
@media (prefers-reduced-motion: no-preference){
  .enf .flow > .node{ opacity:0; transform:translateY(6px); animation:enfFade .36s ease-out forwards; }
  .enf .flow > .node:nth-of-type(1){ animation-delay:.05s; }
  .enf .flow > .node:nth-of-type(2){ animation-delay:.12s; }
  .enf .flow > .node:nth-of-type(3){ animation-delay:.19s; }
  .enf .flow > .node:nth-of-type(4){ animation-delay:.26s; }
  .enf .lane:hover .arrow{ animation:arrowPulse 1.9s ease-in-out infinite; }
  .enf .node:hover{ transform:translateY(-2px); box-shadow:0 2px 0 rgba(255,255,255,.03), 0 10px 26px rgba(0,0,0,.22); }
  @keyframes enfFade{ from{opacity:0; transform:translateY(10px)} to{opacity:1; transform:translateY(0)} }
  @keyframes arrowPulse{ 0%,100%{opacity:.35} 50%{opacity:.80} }
}

/* =========================================================
   FLOWS / EVENTS – Header controls (flat, scoped)
   ========================================================= */
.widget[data-widget-id="events"] select.inp{
  height:30px; padding:4px 10px; border-radius:6px;
  background:var(--panel2); color:var(--txt); border:1px solid var(--border);
  box-shadow:none; outline:none; -webkit-appearance:none; -moz-appearance:none; appearance:none;
  padding-right:26px;
}
.widget[data-widget-id="events"] select.inp:hover{
  background: color-mix(in srgb, var(--panel2) 85%, #000 15%);
  border-color: color-mix(in srgb, var(--border) 80%, var(--link) 20%);
}
.widget[data-widget-id="events"] select.inp:focus-visible{ outline:2px dashed var(--link); outline-offset:2px; }
html[data-theme="light"] .widget[data-widget-id="events"] select.inp{ background:#eef2ff; border-color:var(--border); }
html[data-theme="light"] .widget[data-widget-id="events"] select.inp:hover{ background:#e3e9ff; }
.widget[data-widget-id="events"] #evManualRefresh.btn{ font-weight:800; }

/* =========================================================
   SAFETY BELT — evita o conteúdo por baixo da sidebar
   (não destrutivo: é zerado automaticamente quando a DOM
    está correta — .sidebar seguida por #desktop)
   ========================================================= */
#desktop{ margin-left: var(--sidebar-w); }                     /* default: reserva espaço */
.sidebar + #desktop,
.sidebar ~ #desktop{ margin-left: 0; }                         /* se vier como irmão da sidebar, zera */
@media (max-width: 860px){ #desktop{ margin-left:0 !important; } }  /* mobile nunca desloca */

@supports(selector(:has(*))){
  /* Em navegadores com :has, garantimos a lógica de forma mais precisa */
  body:has(.sidebar) #desktop{ margin-left: var(--sidebar-w); }
  .app:has(.sidebar + #desktop) #desktop{ margin-left: 0; }
}
