/* =========================================================
   Base / Layout
   ========================================================= */

:root{
  --vardr-accent: #2563EB;
  --vardr-accent-hover: #1D4ED8;
  --vardr-accent-focus: #2563EB;
  --vardr-bg: #FBFBFC;          /* app canvas */
  --vardr-surface: #FFFFFF;     /* cards */
  --vardr-border: #E6E8EE;
  --vardr-shadow: 0 1px 1px rgba(16,24,40,0.06);
  --vardr-radius: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Arial, sans-serif;
  margin: 0;
}

/* =========================================================
   App shell: operational layer background (non-auth only)
   ========================================================= */
body:not(.auth-surface) {
  background: var(--vardr-bg); /* solid, clean, no texture */
}

/* =========================================================
   Auth surfaces: atmospheric background (login/signup/etc)
   Scoped via body.auth-surface
   ========================================================= */

body.auth-surface {
  background: #fff;
  min-height: 100vh;
}

/* Disable the old gradient/noise on auth pages */
body.auth-surface::before,
body.auth-surface::after {
  content: none;
}

/* keep foreground above the backdrop layers */
body.auth-surface .container {
  position: relative;
  z-index: 1;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px; /* no top/bottom padding so the header sits flush to the browser */
}

.main {
  padding: 16px 0;
}

.card{
  background: var(--vardr-surface);
  border: 1px solid var(--vardr-border);
  border-radius: var(--vardr-radius);
  box-shadow: var(--vardr-shadow);

  padding: 16px;
  margin: 12px 0;
  overflow: hidden;
}

/* =========================================================
   Auth-only layout adjustments
   ========================================================= */

body.auth-surface .header,
body.auth-surface .footer {
  display: none;
}

/* Auth layout: center the card and avoid 100vh + padding overflow */
body.auth-surface {
  overflow-x: hidden;
}

/* Use the auth hooks from base.html (auth-container/auth-main) */
body.auth-surface .auth-container {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
}

body.auth-surface .auth-main {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  box-sizing: border-box;
}

/* =========================================================
   Header / Footer (full bleed borders)
   ========================================================= */

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  position: relative;
  border-bottom: 0;
}



/* v2: Header is flat white (no atmospheric layers)
   NOTE: do NOT disable ::before/::after here — those are used for the full-bleed
   white bar + bottom divider later in this file.
*/
body:not(.auth-surface) .header{
  background: #fff;
}

/* HARD boundary between atmosphere and work */
body:not(.auth-surface) .header-boundary {
  display: none;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: baseline;
}

.brand-link {
  font-weight: 700;
  text-decoration: none;
  color: #111;
  font-size: 20px;
}

.tagline {
  color: #666;
  font-size: 13px;
}

/* =========================================================
   Step 5 — Full-bleed flat header background (robust)
   The header lives inside `.container` (max-width), so we paint a 100vw
   background using a pseudo-element.
   ========================================================= */

body:not(.auth-surface) .header{
  position: sticky;
  top: 0;
  z-index: 300;

  /* Fallback: ALWAYS white even if pseudo-element stacking breaks */
  background: #fff;
  border-bottom: none; /* divider is painted full-bleed via ::after */
}

/* Full-bleed white bar (painted behind header content) */
body:not(.auth-surface) .header::before{
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100vw;
  height: 100%;

  background: #fff;

  pointer-events: none;
  z-index: 0; /* IMPORTANT: do not use -1 (can disappear behind the page) */
}

/* Full-bleed bottom divider line */
body:not(.auth-surface) .header::after{
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100vw;
  height: 1px;
  background: var(--vardr-border);

  pointer-events: none;
  z-index: 0; /* keep under header content */
}

/* Ensure header content sits above the painted bar */
body:not(.auth-surface) .header > *{
  position: relative;
  z-index: 1;
}

/* =========================================================
   Top nav: stacked brand + true centered primary nav + badge right
   ========================================================= */

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

/* fixed columns to allow true centering */
.brand-stack {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  white-space: nowrap;
}

.brand-stack .tagline {
  margin: 0;
  line-height: 1.2;
}

.nav-center {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
}

.header-right {
  flex: 0 0 220px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

/* new nav-link styling (calm) */
.nav-link {
  text-decoration: none;
  color: #111;
  font-size: 14px;
  padding: 8px 6px;
  border-radius: 10px;
  transition: background 120ms ease;
}

.nav-link:hover {
  background: #fafafa;
}

.nav-link:focus-visible {
  outline: 2px solid var(--vardr-accent-focus);
  outline-offset: 2px;
}

/* subtle active state */
.nav-link.active {
  font-weight: 600;
  text-decoration: none;
  position: relative;
}

.nav-link.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -10px;
  height: 2px;
  background: var(--vardr-accent);
  border-radius: 2px;
}

/* keep existing .nav a rule from interfering */
.nav a {
  margin-left: 0; /* stop left-margin from creating uneven spacing */
}

/* responsive: hide tagline first */
@media (max-width: 760px) {
  .brand-stack {
    flex-basis: 160px;
  }
  .header-right {
    flex-basis: 160px;
  }
  .brand-stack .tagline {
    display: none;
  }
  .nav-center {
    gap: 10px;
  }
}

/* Logout button inside user dropdown should look like a menu item */
.user-dropdown form button.user-dd-item {
  background: none;
  border: 0;
  padding: 10px 10px;
  width: 100%;
  text-align: left;
  border-radius: 10px;
  color: #111;
}

/* Ensure logout never inherits the global `button.danger` black fill */
.user-dropdown form button.user-dd-item.danger {
  background: none;
  color: #111;
}

/* Subtle destructive affordance on hover only */
.user-dropdown form button.user-dd-item.danger:hover {
  background: #f7f7f7;
  color: #111;
}

.nav a {
  margin-left: 0;
  text-decoration: none;
  color: inherit;
}

.footer {
  margin-top: 24px;
  padding-top: 12px;
  color: #777;
  position: relative;
  border-top: none;
}

.footer::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: 100vw;
  height: 1px;
  background: #eee;
}

/* =========================================================
   Typography helpers
   ========================================================= */

label {
  display: block;
  font-size: 13px;
  color: #333;
  margin-top: 10px;
}

.help {
  color: #666;
  font-size: 12px;
  margin-top: 4px;
}

.message {
  background: #f6f6f6;
  padding: 10px 12px;
  border-radius: 10px;
  margin-top: 12px;
}

/* =========================================================
   Form controls
   ========================================================= */

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;

  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;

  height: 36px;
  padding: 0 36px 0 12px;
  margin-top: 6px;

  font-size: 14px;
  line-height: 1.2;

  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23666' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 10px 6px;
}

input,
textarea {
  width: 100%;
  box-sizing: border-box;

  font-size: 14px;
  line-height: 1.3;

  border: 1px solid #ddd;
  border-radius: 10px;
  margin-top: 6px;

  height: 36px;
  padding: 0 12px;

  background: #fff;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible{
  outline: 2px solid var(--vardr-accent-focus);
  outline-offset: 2px;
}

/* -----------------------------------------
   Fix: checkboxes/radios should NOT inherit
   global input sizing
   ----------------------------------------- */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  height: auto;
  padding: 0;
  margin-top: 0;
  border-radius: 4px;
}

textarea {
  height: auto;
  padding: 10px 12px;
}

::placeholder {
  font-size: 14px;
  color: #999;
}

/* Buttons */
button {
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}

button.primary {
  background: var(--vardr-accent);
  color: #fff;
}

button.primary:hover {
  background: var(--vardr-accent-hover);
}

button.primary:focus-visible {
  outline: 2px solid var(--vardr-accent);
  outline-offset: 2px;
}

button.secondary {
  background: #eee;
  color: #111;
}

button.danger {
  background: #111;
  color: #fff;
}

.linkbutton {
  background: none;
  border: none;
  color: #111;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  margin-left: 12px;
}

/* Layout helpers */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.field-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.field-row input[type="number"] {
  flex: 1;
  min-width: 0;
}

.field-row select.unit {
  width: 120px;
  margin-top: 6px;
}

.suffix {
  font-size: 12px;
  color: #666;
  border: 1px solid #ddd;
  background: #fafafa;
  padding: 6px 10px;
  border-radius: 10px;
  white-space: nowrap;
}

/* =========================================================
   Filter pills
   ========================================================= */

.entity-filter {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.filter-pill {
  font-size: 12px;
  padding: 6px 10px;
  border: 1px solid #eee;
  border-radius: 999px;
  background: #fff;
  color: #555;
  cursor: pointer;
}

.filter-pill:hover {
  background: #fafafa;
}

.filter-pill.active {
  border-color: var(--vardr-accent);
  color: var(--vardr-accent);
}

/* =========================================================
   Icon button (shared component)
   - Outline icons via currentColor
   ========================================================= */

.icon-btn {
  cursor: pointer;
  box-sizing: border-box;

  border: 1px solid #ddd;
  background: #fff;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  user-select: none;
  padding: 0;

  color: #333;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.icon-btn:hover {
  background: #fafafa;
}

.icon-btn:active {
  transform: translateY(1px);
}

.icon-btn:focus-visible {
  outline: 2px solid var(--vardr-accent-focus);
  outline-offset: 2px;
}

/* Size variants */
.icon-btn.icon-sm {
  width: 20px;
  height: 20px;
  border-radius: 10px;
  margin-bottom: 1.5em;
}

.icon-btn.icon-md {
  width: 40px;
  height: 40px;
  border-radius: 12px;
}

/* SVG defaults (works with your macro icons) */
.icon-btn svg {
  width: 18px;
  height: 18px;
  display: block;

  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Danger variant */
.icon-btn.danger {
  cursor: pointer;
  box-sizing: border-box;

  border: 1px solid #ddd;
  background: #fff;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  user-select: none;
  padding: 0;

  color: #333;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;             /* neutral default */
}

.icon-btn.danger:hover {
  background: #fafafa;
  border-color: #ddd;
  color: #dc2626;           /* muted red on hover */
}

/* =========================================================
   Entities list UI
   ========================================================= 


.entity-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.entity-main {
  min-width: 0;
} */

.entity-title-line {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.entity-title {
  font-weight: 600;
  color: #111;
}

.entity-inactive {
  color: #a00;
  font-weight: 500;
  margin-left: 6px;
}

.entity-pill {
  font-size: 12px;
  padding: 2px 8px;
  border: 1px solid #ddd;
  border-radius: 999px;
  color: #444;
  background: #fafafa;
}

.entity-meta {
  color: #666;
  font-size: 13px;
  margin-top: 6px;
}

/*
.entity-side {
  min-width: 220px;
  flex-shrink: 0;
  text-align: right;
}

.entity-side-line {
  color: #666;
  font-size: 13px;
  margin-top: 6px;
}
*/
.entity-side-line.muted {
  color: #999;
}

.entity-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

/* Inline edit area */
.entity-edit {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #f0f0f0;
}

.entity-row.editing .entity-edit {
  display: block;
}

.entity-edit-form {
  max-width: 520px;
}

.entity-edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
}

.entity-edit-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

/* =========================================================
   Entities list UI - V2
   ========================================================= */
/* === Vardr UI: Step 3 — Entities as cards (override legacy row list) === */

.entity-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.entity-row {
  padding: 1px 16px 16px;
  border: 1px solid var(--vardr-border);
  border-radius: var(--vardr-radius);
  /* border-bottom: none;  kill legacy divider */
  background: var(--vardr-surface);
  box-shadow: var(--vardr-shadow);
  margin: 0;
  margin-bottom: 16px
}

.entity-row + .entity-row {
  border-top: 1px solid var(--vardr-border); /* harmless; kept for safety */
}

/* RAG status dot (placeholder) */
.rag-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  background: #bbb; /* default neutral */
}

.rag-dot.green { background: #16a34a; }
.rag-dot.amber { background: #f59e0b; }
.rag-dot.red   { background: #dc2626; }

.page-intro{
  display:flex;
  align-items:center;
  gap:16px;
  width:100%;
  box-sizing:border-box;
}

.page-intro button.primary {
  margin-top: 2px;
}

.page-intro > :first-child{
  flex:1;
  min-width:0;
}

.page-intro > :last-child{
  flex-shrink:0;
  margin-left:auto;
}

.page-title{
  margin:0;
  font-size: 40px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.page-subtitle{
  margin-top: 10px;
  color:#5b616e;
  font-size:16px;
}

.filter-card{
  margin: 0 0 18px 0;
}

.filter-label{
  font-size:12px;
  letter-spacing: 0.08em;
  color:#6b7280;
  font-weight:700;
  margin-bottom: 12px;
  text-transform: uppercase;
}


/* =========================================================
   Modal (shared)
   ========================================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 9999;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 480px;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.20);
}

.modal-title {
  font-weight: 650;
  font-size: 16px;
  color: #111;
}

.modal-body {
  color: #555;
  font-size: 13px;
  margin-top: 10px;
  line-height: 1.35;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

.modal-actions form {
  margin: 0;
}

.modal-details {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #f0f0f0;
}

.modal-details summary {
  cursor: pointer;
  font-size: 12px;
  color: #999;
  user-select: none;
}

/* =========================================================
   Entities: modal footer always reachable (vardr modal)
   ========================================================= */

.vardr-modal {
  max-height: min(84vh, 760px);
  display: flex;
  flex-direction: column;
}

.vardr-modal .vardr-modal-scroll {
  overflow: auto;
  padding-bottom: 6px;
}

.vardr-modal .vardr-modal-footer {
  position: sticky;
  bottom: 0;
  background: #fff;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-top: 12px;
  margin-top: 12px;
}

/* =========================================================
   Topic bar (Google-ish)
   ========================================================= */

.topic-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
}

.topic-bar input {
  width: 100%;
  border: none;
  outline: none;
  font-size: 15px;
  background: transparent;
}

/* =========================================================
   Gentle reveal for “options”
   ========================================================= */

.reveal {
  overflow: hidden;
  max-height: 0px;
  opacity: 0;
  transform: translateY(-4px);
  transition: max-height 360ms ease, opacity 360ms ease, transform 360ms ease;
}

.reveal.is-open {
  max-height: 500px;
  opacity: 1;
  transform: translateY(0);
}

/* =========================================================
   Owner choice: pill buttons
   ========================================================= */

.owner-choice {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.owner-btn {
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 170px;
  text-align: center;
  line-height: 1.2;
  user-select: none;
}

.owner-btn.active {
  border-color: rgba(0, 0, 0, 0.35);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
  font-weight: 600;
}

/* Primary button disabled */
.btn-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* =========================================================
   Alerts screen
   ========================================================= */

.alert-actions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  gap: 10px;
  align-items: flex-start;
  justify-content: flex-end;
  margin-top: 2px;
}

.alert-actions details {
  width: auto;
}

.alert-actions summary {
  list-style: none;
}

.alert-actions summary::-webkit-details-marker {
  display: none;
}

.alert-actions summary::marker {
  content: "";
}

/* =========================================================
   Alerts: show action icons only on hover / focus
   - Keeps actions in-position (no layout shift)
   - Keyboard accessible via :focus-within
   ========================================================= */

/* Hide by default */
.alert-item .alert-actions{
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  top: -2px;
  position: relative;
  transition: opacity 160ms ease, top 160ms ease, visibility 0s linear 160ms;
}

/* Reveal on hover, when the alert is expanded, or when actions themselves are focused/open */
.alert-item:hover .alert-actions,
.alert-item.is-open .alert-actions,
.alert-item .alert-actions:focus-within,
.alert-item .alert-actions details[open] {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  top: 0;
  transition: opacity 160ms ease, top 160ms ease, visibility 0s;
}

/* Touch devices don't have hover — keep actions visible */
@media (pointer: coarse){
  .alert-item .alert-actions{
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition: none;
  }
}

/* =========================================================
   Attention: alert row contract (collapsed/expanded)
   ========================================================= */

.alert-item{
  padding: 0;
  border-bottom: 1px solid #eee;
}

.alert-row{
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 16px 0;
}

/* Left area toggles expansion */
.alert-left{
  min-width: 0;
  flex: 1;
  cursor: pointer;
}

.alert-left:focus-visible{
  outline: 2px solid var(--vardr-accent-focus);
  outline-offset: 2px;
  border-radius: 10px;
}

.alert-title-line{
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.alert-title{
  font-weight: 700;
  font-size: 16px;
  color: #111;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

  .alert-chev{
    width: 14px;
    height: 14px;
    flex: 0 0 14px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    color: #bbb;
    transition: transform 120ms ease, color 120ms ease;
  }

  .alert-chev svg{
    width: 14px;
    height: 14px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.25;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

.alert-meta-line{
  color: #666;
  font-size: 13px;
  margin-top: 6px;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alert-meta-line .dot{
  color: #bbb;
  margin: 0 6px;
}

/* Expanded blocks (inline, no nested card, no borders) */
.alert-expanded{
  display: none;
  margin-top: 12px;
}

.alert-item.is-open .alert-expanded{
  display: block;
}

.alert-item.is-open .alert-chev{
  transform: rotate(90deg);
  color: var(--vardr-accent);
}

.alert-cause{
  font-weight: 700;
  color: #111;
}

.alert-evidence{
  margin-top: 12px;
  color: #444;
  font-size: 13px;
  line-height: 1.35;
}

.alert-evidence > div{
  margin-top: 6px;
}

.alert-config-link{
  margin-top: 12px;
  font-size: 12px;
  color: #777;
}

.alert-config-link a{
  color: #777;
}

.alert-config-link a:hover{
  text-decoration: underline;
}

.alert-ack-line{
  color: #666;
  font-size: 13px;
  margin-top: 10px;
}


/* =========================================================
   Alerts: action popovers (no layout shift)
   ========================================================= */

.alert-actions details.action-pop {
  position: relative; /* anchor for the panel */
}

/* Make icon buttons participate in stacking so the popover can sit above them */
.alert-actions .icon-btn,
.alert-actions > a.icon-btn{
  position: relative;
  z-index: 0;
}

/* Keep the clicked summary above its siblings (but still below the panel) */
.alert-actions details.action-pop[open] > summary.icon-btn{
  z-index: 3000;
}

/* Ensure popover stacks above the icon buttons */
.alert-actions{
  position: relative; /* create a stacking context */
  z-index: 1;
}

.alert-actions details.action-pop{
  z-index: 1; /* default */
}

.alert-actions details.action-pop[open]{
  z-index: 1200; /* above sibling icon buttons */
}

/* kill the default marker in a generic way */
.alert-actions summary {
  list-style: none;
}
.alert-actions summary::-webkit-details-marker {
  display: none;
}
.alert-actions summary::marker {
  content: "";
}

/* the popover panel */
.alert-actions .action-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);

  /* matches your existing inline styles */
  min-width: 220px;
  max-width: 260px;
  padding: 10px;
  border: 1px solid #eee;
  border-radius: 12px;
  background: #fff;

  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
  z-index: 5000;

  /* IMPORTANT: remove layout shift */
  margin-top: 0;
  display: none;
}

.alert-actions details.action-pop[open]{
  z-index: 3000; /* lift the whole open popover above sibling icons */
}

.alert-actions details.action-pop[open] > .action-panel {
  display: block;
}

/* Acknowledge: neutral by default, accent only on intent */
.alert-actions details.action-pop:first-child > summary.icon-btn{
  border-color: #ddd;
  color: #333;
}

.alert-actions details.action-pop:first-child > summary.icon-btn:hover{
  background: rgba(37, 99, 235, 0.06);
  border-color: rgba(37, 99, 235, 0.45);
  color: var(--vardr-accent);
}

.alert-actions details.action-pop:first-child > summary.icon-btn:focus-visible{
  outline: 2px solid var(--vardr-accent-focus);
  outline-offset: 2px;
  border-color: rgba(37, 99, 235, 0.45);
  color: var(--vardr-accent);
}

/* Allow alert popovers to escape the card */
.alert-item {
  position: relative;
}

.alert-item > div {
  overflow: visible;
}

/* Alerts card must not clip popovers */
.card.alerts-card {
  overflow: visible;
}



/* =========================================================
   Rules screen (details rows + tooltips)
   ========================================================= */

/* Remove default disclosure triangle so our chevron is the affordance */
.rule-item > summary {
  list-style: none;
}

.rule-item > summary::-webkit-details-marker {
  display: none;
}

.rule-summary {
  cursor: pointer;
  user-select: none;

  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;

  padding: 0; /* aligns with card padding */
  border-radius: 10px;
  position: relative; /* for hover background */
}

.rule-summary::before {
  content: "";
  position: absolute;
  inset: -8px -10px; /* grow hover hit area */
  border-radius: 10px;
  background: transparent;
  transition: background 120ms ease;
  z-index: 0;
}

.rule-summary:hover::before {
  background: #fafafa;
}

.rule-summary > * {
  position: relative;
  /*z-index: 1;*/
}

.rule-title {
  font-weight: 650;
  color: #111;
  font-size: 16px;
  line-height: 1.2;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rule-summary-meta {
  margin-top: 6px;

  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;

  color: #666;
  font-size: 13px;
  line-height: 1.25;
}

.rule-summary-meta strong {
  color: #111;
  font-weight: 650;
}

.rule-pill {
  font-size: 12px;
  padding: 2px 8px;
  border: 1px solid #ddd;
  border-radius: 999px;
  color: #444;
  background: #fafafa;
}

.rule-summary-cta {
  flex-shrink: 0;
  display: inline-flex;
  gap: 8px;
  align-items: center;

  color: #999;
  font-size: 12px;
}

.rule-chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid #bbb;
  border-bottom: 2px solid #bbb;
  transform: rotate(45deg);
  margin-top: 2px;
}

.rule-item[open] .rule-chevron {
  transform: rotate(-135deg);
  margin-top: 6px;
}

.rule-advanced-summary {
  cursor: pointer;
  user-select: none;

  display: inline-flex;
  align-items: center;
  gap: 8px;

  color: #666;
  font-size: 13px;
}

.rule-advanced-summary::-webkit-details-marker {
  display: none;
}

.rule-advanced-chevron {
  width: 7px;
  height: 7px;
  border-right: 2px solid #bbb;
  border-bottom: 2px solid #bbb;
  transform: rotate(45deg);
}

.rule-advanced[open] .rule-advanced-chevron {
  transform: rotate(-135deg);
}

.rule-status {
  margin-top: 14px;
}

.rule-status-row {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

/* Tooltip trigger */
.tip-btn {
  width: 18px;
  height: 18px;
  padding: 0;
  margin-left: 6px;
  border-radius: 999px;
  border: 1px solid #ddd;
  background: #fff;
  color: #777;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
}

.tip-btn:hover {
  background: #fafafa;
  color: #555;
}

/* Tooltip popup: floating card */
.tip-pop {
  display: none;
  border: 1px solid #eee;
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.10);
  max-width: 520px;

  position: fixed;
  z-index: 10000;

  top: 0;
  left: 0;
}

.tip-pop.active {
  display: block;
}

.tip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.tip-title {
  font-weight: 650;
  color: #111;
  font-size: 13px;
}

.tip-body {
  color: #555;
  font-size: 13px;
  line-height: 1.35;
}

.tip-close {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 1px solid #eee;
  background: #fff;
  cursor: pointer;
  padding: 0;
  line-height: 26px;
  font-size: 16px;
  color: #666;
}

.tip-close:hover {
  background: #fafafa;
  color: #111;
}

.tip-close:focus-visible {
  outline: 2px solid var(--vardr-accent-focus);
  outline-offset: 2px;
}

/* =========================================================
   User menu
   ========================================================= */

.user-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.user-chip {
  border: 1px solid #e5e5e5;
  background: #fff;
  border-radius: 999px;
  padding: 4px;
  cursor: pointer;
  line-height: 0;
}

.user-chip:hover {
  background: #fafafa;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #222;
  background: #f2f2f2;
  user-select: none;
}

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 180px;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
  padding: 8px;
  display: none;
  z-index: 600;
}

.user-dropdown.active {
  display: block;
}

.user-dd-item {
  display: block;
  padding: 10px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: #111;
  font-size: 14px;
}

.user-dd-item:hover {
  background: #f7f7f7;
}

.user-dd-item.danger {
  color: #111;
}

.user-dd-sep {
  height: 1px;
  background: #eee;
  margin: 6px 0;
}

/* =========================================================
   Auth surfaces (Login / Signup / Reset / Verify)
   Scope: ONLY auth templates should use these classes.
   ========================================================= */

/*
  Auth templates may wrap content in .auth-page.
  The true centering + padding is handled by body.auth-surface .auth-main.
  Keep .auth-page neutral to avoid double-centering + tiny overflow.
*/
.auth-page {
  min-height: auto;
  padding: 0;
  box-sizing: border-box;
  display: block;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  margin: 0;
  border: 1px solid #eee;
  border-radius: 12px;
  padding: 24px;
  background: #fff;

  /* Typography: Inter on auth only */
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.auth-brand {
  font-size: 28px;
  font-weight: 600;
  color: #111;
  line-height: 1.1;
}

.auth-tagline {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 400;
  color: #666;
}

.auth-head {
  margin-top: 24px;
}

.auth-title {
  font-size: 22px;
  font-weight: 600;
  color: #111;
  line-height: 1.2;
}

.auth-context {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 400;
  color: #666;
  line-height: 1.35;
}

.auth-form {
  margin-top: 24px;
}

.auth-field + .auth-field {
  margin-top: 16px;
}

.auth-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  margin-top: 0;
}

/* Input text size on auth */
.auth-card input {
  font-size: 16px;
}

/* Primary button: full width on auth */
button.primary.auth-primary {
  width: 100%;
  margin-top: 24px;
}

.auth-links {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 400;
}

.auth-link {
  color: var(--vardr-accent);
  text-decoration: none;
}

.auth-link:hover {
  text-decoration: underline;
}

.auth-link:focus-visible {
  outline: 2px solid var(--vardr-accent-focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.auth-links-sep {
  color: #bbb;
}

.auth-footer {
  margin-top: 24px;
  font-size: 12px;
  font-weight: 400;
  color: #999;
  text-align: center;
}


/* =========================================================
   Auth: error banner + error input borders (login)
   ========================================================= */

/* Stack for auth banner + auth card (keeps banner near the card) */
body.auth-surface .auth-stack{
  width: 100%;
  max-width: 440px;   /* match .auth-card */
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;           /* ~0.5em at 16px base */
}

/* Banner shown above the auth card when a login error occurs */
.login-error-banner{
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;

  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.45);
  color: #b91c1c;

  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.35;
}

/* If older templates still use .message on auth pages, style it like the error banner */
body.auth-surface .auth-main .message{
  width: 100%;
  max-width: 440px;
  margin: 0 auto 14px auto;
  padding: 12px 14px;
  border-radius: 12px;

  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.45);
  color: #b91c1c;

  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.35;
}

/* If we show the banner (now outside the card), tint inputs inside the auth card */
body.auth-surface .auth-stack .login-error-banner ~ .auth-page .auth-card input,
body.auth-surface .auth-stack .login-error-banner ~ .auth-page .auth-card textarea,
body.auth-surface .auth-stack .login-error-banner ~ .auth-page .auth-card select{
  border-color: rgba(220, 38, 38, 0.55);
}

/* Error borders for login inputs when an error banner/message is present */
body.auth-surface .auth-card.has-error input,
body.auth-surface .auth-card.has-error textarea,
body.auth-surface .auth-card.has-error select{
  border-color: rgba(220, 38, 38, 0.55);
}

/* Heuristic selectors: if the error banner/message sits before the form, tint inputs */
body.auth-surface .auth-card .login-error-banner ~ .auth-form input,
body.auth-surface .auth-card .login-error-banner ~ form input,
body.auth-surface .auth-card .message ~ .auth-form input,
body.auth-surface .auth-card .message ~ form input{
  border-color: rgba(220, 38, 38, 0.55);
}

/* Focus state for error inputs */
body.auth-surface .auth-card.has-error input:focus-visible,
body.auth-surface .auth-card.has-error textarea:focus-visible,
body.auth-surface .auth-card.has-error select:focus-visible,
body.auth-surface .auth-card .login-error-banner ~ .auth-form input:focus-visible,
body.auth-surface .auth-card .login-error-banner ~ form input:focus-visible,
body.auth-surface .auth-card .message ~ .auth-form input:focus-visible,
body.auth-surface .auth-card .message ~ form input:focus-visible{
  outline: 2px solid rgba(220, 38, 38, 0.65);
  outline-offset: 2px;
}









/* === Vardr UI: Step 1 — Canvas + Card surfaces only === */

/* App canvas */
html, body { height: 100%; }

/* Avatar: solid blue circle (if it's currently just a pill) */
.avatar,
.user-avatar,
.profile-avatar {
  background: #2F61D4 !important;
  color: #fff !important;
  border: none !important;
  box-shadow: none !important;
}

/* =========================================================
   Entities card layout — lock alignment + indentation
   Paste at END of styles.css so it wins.
   ========================================================= */

/* 3-column card grid */
.entity-grid{
  display: grid;
  grid-template-columns: 1.15fr 1fr 200px; /* matches your devtools + reference */
  gap: 28px;
  align-items: start;
}

/* Column wrappers */
.entity-left{ min-width: 0; }
.entity-middle{ min-width: 0; }
.entity-right{
  min-width: 0;
  justify-self: end;
  text-align: right;
}

/* Title row becomes a grid so dot doesn't "steal" the left edge */
.entity-title-line{
  display: grid;
  grid-template-columns: 10px 1fr auto; /* dot | title | pill */
  column-gap: 12px;
  align-items: center;
  margin-bottom: 10px;
  min-width: 0;
}

/* Dot never affects spacing beyond its own column */
.rag-dot{
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: block;
}

/* Title must not wrap (wrapping changes perceived indentation) 
.entity-title{
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}*/
.entity-title-text{
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 800;
  font-size: 20px; /* tweak if needed, but keeps reference feel */
  line-height: 1.05;
  letter-spacing: -0.02em;
}

/* Pill stays compact and consistent */
.entity-pill{
  justify-self: start;
  margin-left: 8px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f3f4f6;
  border: 1px solid rgba(0,0,0,0.06);
  color: #374151;
}

/* KV blocks */
.kv{
  margin: 0;
}

/* This is the KEY: align KV content under the title text, not under the dot */
.entity-left .kv,
.entity-middle .kv{
  padding-left: 0px; 
}

.kv-label{
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
  margin-bottom: 6px;
}

.kv-value{
  font-size: 12px;
  color: #111827;
  font-weight: 600;
  line-height: 1.25;
}

/* Chip styling for tracking phrase */
.chip{
  display: inline-flex;
  align-items: center;
  height: 27px;
  padding: 0 12px;
  border-radius: 10px;
  background: #f3f4f6;
  border: 1px solid rgba(0,0,0,0.06);
  color: #111827;
  font-weight: 600;
}

/* Right column: frequency above actions like the reference */
.kv.kv-right{
  padding-left: 0;
}
.entity-actions{
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

/* =========================================================
   Entity header row (new structure)
   ========================================================= */

.entity-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-width: 0; /* critical: allows left side to shrink instead of forcing overflow */
}

.entity-head-left{
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto; /* take remaining space */
}

.entity-head-right{
  display: flex;
  align-items: center;
  flex: 0 0 auto; /* do NOT grow */
}

/* Ensure the action buttons never wrap / never collapse vertically */
.entity-actions{
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

/* Title container should be the “shrinkable” part */
.entity-title{
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

/* Your call: keep name on one line without ellipsis.
   This will CLIP if it truly can’t fit, but it won’t push buttons around. */
.entity-title-text{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip; /* explicitly NOT ellipsis */
}

/* Keep the pill from getting crushed oddly */

.entity-pill{
  flex: 0 0 auto;
}

/* =========================================================
   Entities: show action icons only on hover / focus
   - Keeps actions in-position (no layout shift)
   - Keyboard accessible via :focus-within
   ========================================================= */

/* Entity action icons: borderless (match calm console) */
.entity-row .entity-actions .icon-btn{
  border-color: transparent;
}

.entity-row .entity-actions{
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity 160ms ease, transform 160ms ease, visibility 0s linear 160ms;
  will-change: opacity, transform;
}

.entity-row:hover .entity-actions,
.entity-row:focus-within .entity-actions{
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

/* Touch devices don't have hover — keep actions visible */
@media (pointer: coarse) {
  .entity-row .entity-actions{
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
}

.rag-dot{
  width:10px;
  height:10px;
  border-radius:999px;
  display:inline-block;
  flex:0 0 auto;
  background:#9bb3a1;
  box-shadow:0 0 0 1px rgba(0,0,0,0.06) inset;
  transition: background-color 180ms ease, box-shadow 180ms ease;
}
 .rag-dot.rag-green{ background:#CFF3DC; }
 .rag-dot.rag-amber{ background:#FFE3B3; }
 .rag-dot.rag-red{ background:#FAD1D1; }

/* Alias legacy classes to the newer rag-* palette */
.rag-dot.green { background:#CFF3DC; }
.rag-dot.amber { background:#FFE3B3; }
.rag-dot.red   { background:#FAD1D1; }

/* RAG: unknown status = outlined dot (no fill) */
.rag-dot.rag-unknown{
  background: transparent;
  box-shadow: none;
  opacity: 1;
  border: 1px solid rgba(0,0,0,0.35);
}


/* =========================================================
   Login: subtle expanding rings (login only)
   Rendered by base.html as #login-rings
   ========================================================= */

#login-rings{
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

/* keep the login card above the ring layer */
body.auth-surface .auth-main,
body.auth-surface .container{
  position: relative;
  z-index: 1;
}

.login-ring{
  position: absolute;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.28);
  background: transparent;

  /* center the ring on the chosen x/y */
  transform: translate(-50%, -50%) scale(0.65);
  opacity: 0;

  animation: loginRingExpand 8s ease-out forwards;
  will-change: transform, opacity;
}

@keyframes loginRingExpand{
  0%   { opacity: 0;   transform: translate(-50%, -50%) scale(0.65); }
  10%  { opacity: 0.38; }
  100% { opacity: 0;   transform: translate(-50%, -50%) scale(8.0); }
}

@media (prefers-reduced-motion: reduce){
  #login-rings{ display: none; }
}





/* Silence progress bar (under Silence window) */
.silence-progress{
  width: 140px;
  height: 6px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(0,0,0,0.06);
  overflow: hidden;
}

.entity-right .silence-progress{
  margin-left: auto;
}

.silence-progress-fill{
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 400ms ease;
}

/* Default (approaching/within silence window): neutral grey so it doesn't clash with RAG */
.silence-progress-fill{
  background: rgba(0,0,0,0.18);
}

/* Urgency only increases intensity (same neutral hue) */
.entity-row[data-urgency="warn"] .silence-progress-fill{ background: rgba(0,0,0,0.28); }
.entity-row[data-urgency="critical"] .silence-progress-fill{ background: rgba(0,0,0,0.36); }

/* Cooldown mode: switch to Vardr accent blue */
.entity-row[data-urgency="cooldown"] .silence-progress-fill,
.silence-progress[data-urgency="cooldown"] .silence-progress-fill{
  background: rgba(37, 99, 235, 0.60);
}

.entity-row[data-urgency="cooldown"] .silence-progress,
.silence-progress[data-urgency="cooldown"]{
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.30) inset;
}

/* If urgency is applied to the bar itself (not the row), keep behaviour consistent */
.silence-progress[data-urgency="warn"] .silence-progress-fill{ background: rgba(0,0,0,0.28); }
.silence-progress[data-urgency="critical"] .silence-progress-fill{ background: rgba(0,0,0,0.36); }

/* =========================================================
   Pulse: RED only (single source of truth)
   ========================================================= */

@keyframes vardr_red_pulse{
  0%   { transform: scale(1);    opacity: 1; }
  50%  { transform: scale(1.12); opacity: 0.72; }
  100% { transform: scale(1);    opacity: 1; }
}



/* iOS-style text sheen (Option 2) */
.last-evaluated[data-live="1"]{
  position: relative;
  display: inline-block;
  overflow: visible;
  isolation: isolate;
}

/* the sheen */
.last-evaluated[data-live="1"]::before{
  content: "";
  position: absolute;
  inset: -2px -8px;
  pointer-events: none;
  z-index: 1;

  /* thin diagonal highlight */
  background: linear-gradient(
    115deg,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,0) 40%,
    rgba(255,255,255,0.55) 50%,
    rgba(255,255,255,0) 60%,
    rgba(255,255,255,0) 100%
  );

  opacity: 0;
  transform: translateX(-140%);
  filter: blur(0.3px);

  /* iOS-like: long idle, quick sweep */
  animation: vardr_sheen 8s ease-in-out infinite;
}

@keyframes vardr_sheen{
  0%, 72%   { opacity: 0; transform: translateX(-140%); }
  75%       { opacity: 0.9; }
  86%       { opacity: 0.9; transform: translateX(140%); }
  90%, 100% { opacity: 0; transform: translateX(140%); }
}

/* respect reduced motion */
@media (prefers-reduced-motion: reduce){
  .last-evaluated[data-live="1"]::before{ animation: none !important; }
}

/* =========================================================
   Source icons (inline brand/news glyphs)
   - Prevent 0x0 SVG rendering in inline contexts
   ========================================================= */

.source-icon{
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 19px;
  height: 19px;

  margin-left: 10px;           /* space from “Discussed 2d ago” */
  flex: 0 0 auto;

  line-height: 1;              /* stop baseline weirdness */
  vertical-align: middle;      /* if it ends up in inline flow */
  overflow: visible;           /* don't clip the SVG */
}

.source-icon svg{
  width: 19px;
  height: 19px;
  display: block;              /* removes inline SVG descender gap */
  padding-right: 1px;
  padding-left: 1px;
}
/* =========================================================
   Source icon brand colours
   - Uses currentColor so SVGs inherit colour
   - Keeps CSS minimal and centralized
   ========================================================= */

:root{
  --source-youtube: #FF0000;
  --source-reddit:  #FF4500;
  --source-mastodon:#6364FF;
  --source-news:    #0078D4;
}

.source-icon.is-youtube{ color: var(--source-youtube); }
.source-icon.is-reddit{ color: var(--source-reddit); }
.source-icon.is-mastodon{ color: var(--source-mastodon); }
.source-icon.is-news{ color: var(--source-news); transform: scale(1.15);transform-origin: center;}

.alert-item:has(details.action-pop[open]) {
  z-index: 100;
  position: relative;
}


/* =========================================================
   Entities: hover emphasis (subtle, calm, deliberate)
   - No animation
   - Slight border strengthening + lift
   ========================================================= */

/* Ensure card is a positioning context */
.entity-row{
  position: relative;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

/* Hover / focus treatment */
.entity-row:hover,
.entity-row:focus-within{
  /* slightly stronger border */
  border-color: var(--vardr-accent-focus);

  /* micro lift for tactility */
  transform: translateY(-2px);
}





