/* ============================================================================
   AppWorkloadPolicies — features.css
   All styling for the app. Extracted from the inline <style> block in
   index.html so the same rules can be reused across pages and cached
   independently by the browser.
   ============================================================================ */

/* ── Design Tokens ────────────────────────────────────────
   Palette inspired by the Blowfish Hugo theme used on
   https://michaeltheadmin.com — orange primary + warm neutral
   (Tailwind "orange" + "stone"). Light theme by default with a
   matching dark palette via prefers-color-scheme.
────────────────────────────────────────────────────────── */
:root {
  /* Brand — orange scale */
  --color-primary:         #F97316; /* orange-500 */
  --color-primary-hover:   #EA580C; /* orange-600 */
  --color-primary-soft:    #FED7AA; /* orange-200 */
  --color-secondary:       #0EA5E9; /* sky-500  — accents */
  --color-tertiary:        #A8A29E; /* stone-400 */

  /* Surfaces (light) — warm neutral / stone */
  --bg-900:   #FFFFFF;               /* app background */
  --bg-800:   #FAFAF9;               /* header / sidebar */
  --bg-700:   #F5F5F4;               /* subtle inputs / table headers */
  --bg-hover: #E7E5E4;               /* hovers */
  --border:   #D6D3D1;               /* borders */

  --text-primary:   #1C1917;         /* stone-900 */
  --text-secondary: #57534E;         /* stone-600 */
  --text-tertiary:  #A8A29E;         /* stone-400 */

  --color-success: #16A34A;
  --color-warning: #D97706;
  --color-error:   #DC2626;

  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  32px;

  /* Configurable via the Font popover (toolbar) */
  --policy-font-size:   12px;
  --policy-font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Configurable via the Row Height popover (toolbar) */
  --policy-row-height:  30px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-primary:       #FB923C; /* orange-400 */
    --color-primary-hover: #F97316; /* orange-500 */
    --color-primary-soft:  #7C2D12; /* orange-900 */
    --color-secondary:     #38BDF8; /* sky-400 */
    --color-tertiary:      #78716C; /* stone-500 */

    --bg-900:   #1C1917; /* stone-900 */
    --bg-800:   #292524; /* stone-800 */
    --bg-700:   #44403C; /* stone-700 */
    --bg-hover: #57534E; /* stone-600 */
    --border:   #57534E;

    --text-primary:   #FAFAF9;
    --text-secondary: #D6D3D1;
    --text-tertiary:  #A8A29E;

    --color-success: #22C55E;
    --color-warning: #F59E0B;
    --color-error:   #F87171;
  }
}

[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-900);
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── App header ─────────────────────────────────────────── */
.app-header {
  background: var(--bg-800);
  border-bottom: 1px solid var(--border);
  padding: var(--space-sm) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.brand { min-width: 0; }
.brand__label {
  color: var(--color-primary);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  line-height: 1.2;
}
.brand__title {
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}
.toolbar-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  flex-shrink: 0;
}
.header-spacer { flex: 1; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-hover); }
.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn--ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--color-tertiary);
}

/* ── Main area ──────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Wrapper that stacks the viewer and the details panel vertically */
.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* ── Drop zone ──────────────────────────────────────────── */
.drop-zone {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  background: var(--bg-900);
  z-index: 20;
  outline: 2px dashed transparent;
  outline-offset: -12px;
  transition: background 0.15s, outline-color 0.15s;
}
.drop-zone.drag-over {
  background: color-mix(in srgb, var(--color-primary) 7%, var(--bg-900));
  outline-color: var(--color-primary);
}
.drop-zone__icon { color: var(--color-primary); opacity: 0.55; }
.drop-zone h1 {
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.4;
}
.drop-zone__desc {
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
  max-width: 48ch;
  line-height: 1.6;
}
.drop-zone__desc code {
  background: var(--bg-700);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 11px;
  color: var(--text-primary);
}
.drop-zone__actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  justify-content: center;
}
.drop-zone__privacy {
  color: var(--text-tertiary);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
}

/* ── Viewer layout ──────────────────────────────────────── */
.viewer {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* ── Date panel (left sidebar) ──────────────────────────── */
.date-panel {
  width: 150px;
  min-width: 150px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-800);
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.date-panel__header {
  padding: var(--space-sm) var(--space-md);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.date-panel__count {
  font-size: 10px;
  font-weight: 600;
  background: var(--bg-700);
  color: var(--text-tertiary);
  padding: 1px 6px;
  border-radius: 12px;
}
.date-panel__list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}
.date-panel__list::-webkit-scrollbar       { width: 6px; }
.date-panel__list::-webkit-scrollbar-track { background: var(--bg-800); }
.date-panel__list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.date-item {
  display: flex;
  flex-direction: column;
  padding: 9px var(--space-md);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  transition: background 0.1s, border-color 0.1s;
  gap: 2px;
}
.date-item:hover { background: var(--bg-hover); }
.date-item.is-active {
  background: color-mix(in srgb, var(--color-primary) 10%, var(--bg-800));
  border-left-color: var(--color-primary);
}
.date-item__date {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}
.date-item__time {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: "Consolas", "Cascadia Code", monospace;
}
.date-item__meta {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-top: 3px;
}
.date-item__badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  background: var(--bg-700);
  color: var(--text-secondary);
}
.date-item.is-active .date-item__badge {
  background: var(--color-primary);
  color: #fff;
}
.date-item__meta-spacer { flex: 1; }
.date-item__copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  flex-shrink: 0;
}
.date-item__copy:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--color-tertiary);
}
.date-item__copy:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}
.date-item__copy.is-copied {
  color: var(--color-success);
  border-color: var(--color-success);
}
.date-item__copy svg { display: block; }
.date-item__file {
  font-size: 10px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* ── Policy panel (right) ───────────────────────────────── */
.policy-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
/* ── Policy table ───────────────────────────────────────── */
.policy-table-wrap {
  flex: 1;
  overflow: auto;
  min-height: 0;
}
.policy-table-wrap:focus { outline: none; }
.policy-table-wrap:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }
.policy-table-wrap::-webkit-scrollbar       { width: 12px; height: 12px; }
.policy-table-wrap::-webkit-scrollbar-track { background: var(--bg-900); }
.policy-table-wrap::-webkit-scrollbar-thumb { background: var(--color-primary); border-radius: 6px; border: 2px solid var(--bg-900); }
.policy-table-wrap::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--color-primary) 70%, transparent); }

.policy-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--policy-font-size);
  font-family: var(--policy-font-family);
  min-width: 960px;
}
.policy-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-700);
  border-bottom: 2px solid var(--border);
  padding: 6px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-secondary);
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}
.policy-table td {
  height: var(--policy-row-height);
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}
.policy-table tbody tr:hover td { background: var(--bg-hover); }
.policy-table td.col-name {
  color: var(--text-primary);
  font-weight: 500;
}
.policy-table td.col-id {
  font-family: "Consolas", "Cascadia Code", monospace;
  color: var(--text-tertiary);
  max-width: 320px;
}
.policy-table td.col-cmd {
  font-family: "Consolas", "Cascadia Code", monospace;
  max-width: 320px;
}
.policy-table td.col-rev {
  text-align: center;
  color: var(--text-tertiary);
}

/* ── Intent / Context badges ────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.badge--required     { background: color-mix(in srgb, var(--color-success)   18%, var(--bg-700)); color: var(--color-success);   }
.badge--available    { background: color-mix(in srgb, var(--color-secondary)  18%, var(--bg-700)); color: var(--color-secondary);  }
.badge--uninstall    { background: color-mix(in srgb, var(--color-error)      18%, var(--bg-700)); color: var(--color-error);      }
.badge--not-targeted { background: var(--bg-700); color: var(--text-tertiary); }
.badge--user         { background: color-mix(in srgb, var(--color-warning)   15%, var(--bg-700)); color: var(--color-warning);    }
.badge--system       { background: color-mix(in srgb, var(--color-secondary)  15%, var(--bg-700)); color: var(--color-secondary);  }

/* ── Empty state ────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-xl);
  color: var(--text-tertiary);
  font-size: 13px;
  height: 100%;
  text-align: center;
}
.empty-state svg { opacity: 0.3; }

/* ── Details panel (bottom) ─────────────────────────────── */
.details-panel {
  background: var(--bg-800);
  border-top: 2px solid var(--color-primary);
  display: flex;
  flex-direction: column;
  /* Default height scales with the viewport: ~45% of window height,
     clamped between 160px (very short windows) and 520px (large
     displays). Drag-resize / toggle still set inline height, but
     max-height keeps it within bounds when the window shrinks. */
  height: clamp(160px, 45vh, 520px);
  min-height: 80px;
  max-height: 70vh;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}
.dp-resize-handle {
  position: absolute;
  top: -3px;
  left: 0;
  right: 0;
  height: 6px;
  cursor: ns-resize;
  z-index: 10;
  border-radius: 3px;
  transition: background 0.15s;
}
.dp-resize-handle:hover,
.dp-resize-handle.is-dragging { background: var(--color-primary); opacity: 0.4; }

.dp-tabs {
  display: flex;
  align-items: stretch;
  background: var(--bg-900);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 34px;
  gap: 0;
}
.dp-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.12s, border-color 0.12s;
}
.dp-tab:hover { color: var(--text-primary); }
.dp-tab.is-active {
  color: var(--text-primary);
  border-bottom-color: var(--color-primary);
}
.dp-tab:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }
.dp-tabs__list {
  display: flex;
  align-items: stretch;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;                     /* Firefox */
  -ms-overflow-style: none;                  /* IE/Edge legacy */
  scroll-behavior: smooth;
}
.dp-tabs__list::-webkit-scrollbar { display: none; } /* WebKit */
.dp-tabs__list.is-scrollable { cursor: grab; }
.dp-tabs__list.is-scrollable:active { cursor: grabbing; }
.dp-tabs__spacer { flex: 1; }

.dp-tab-nav {
  display: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  flex-shrink: 0;
  border: none;
  background: var(--bg-900);
  color: var(--color-primary);
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
  position: relative;
  z-index: 1;
}
.dp-tab-nav.is-visible { display: inline-flex; }
.dp-tab-nav:hover { color: var(--color-primary-hover); background: var(--bg-hover); }
.dp-tab-nav:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }
/* Subtle fade so tabs appear to slide behind the arrows */
.dp-tab-nav--left.is-visible {
  box-shadow: 6px 0 6px -4px color-mix(in srgb, var(--bg-900) 80%, transparent);
}
.dp-tab-nav--right.is-visible {
  box-shadow: -6px 0 6px -4px color-mix(in srgb, var(--bg-900) 80%, transparent);
}
.dp-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.dp-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.dp-close:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }

.dp-body {
  flex: 1;
  overflow: auto;
  min-height: 0;
  padding: var(--space-md);
}
.dp-body::-webkit-scrollbar       { width: 8px; height: 8px; }
.dp-body::-webkit-scrollbar-track { background: var(--bg-800); }
.dp-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.dp-pane { display: none; }
.dp-pane.is-active { display: block; }

.dp-empty {
  color: var(--text-tertiary);
  font-size: 13px;
  text-align: center;
  padding: var(--space-xl);
}

/* ── General tab fields ─────────────────────────────────── */
.dp-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px 24px;
}
.dp-field--full { grid-column: 1 / -1; }
.dp-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.dp-fk {
  font-size: calc(var(--policy-font-size) - 2px);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.dp-fv {
  font-size: var(--policy-font-size);
  color: var(--text-primary);
  font-family: var(--policy-font-family);
  word-break: break-word;
  white-space: pre-wrap;
}
.dp-fv--app-name {
  font-family: var(--policy-font-family);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dp-fv-copy {
  display: inline-block;
  max-width: 100%;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: var(--text-primary);
  font: inherit;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dp-fv-copy:hover { color: var(--color-secondary, #9ecbff); }
.dp-fv-copy.is-copied { color: var(--color-success, #4caf50); }
.dp-fv--signed   { color: var(--color-success); }
.dp-fv--unsigned { color: var(--color-warning); }
.dp-fv--missing  { color: var(--text-tertiary); font-style: italic; }

/* Program tab */
.dp-program__fields {
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 10px 16px;
  align-items: start;
  align-items: start;
}
.dp-program__fields .dp-field--full { grid-column: 1 / -1; }
.dp-program__cmd,
.dp-program__id {
  word-break: break-all;
}
.dp-program__sig {
  display: inline-block;
  margin-left: 10px;
  font-size: 11px;
  letter-spacing: 0.3px;
}
.dp-program__hint {
  margin-left: 6px;
  color: var(--text-tertiary);
  font-size: 11px;
}

/* Cert chain disclosure shown under the detection meta row */
.dp-sig-chain {
  margin: 0 0 var(--space-sm);
  font-size: var(--policy-font-size);
  color: var(--text-secondary);
}
.dp-sig-chain summary {
  cursor: pointer;
  color: var(--text-tertiary);
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  font-size: calc(var(--policy-font-size) - 1px);
  padding: 2px 0;
  -webkit-user-select: none;
  user-select: none;
}
.dp-sig-chain summary:hover { color: var(--text-secondary); }
.dp-sig-chain__items {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dp-sig-chain__cert {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 2px 10px;
  padding: 6px 10px;
  background: var(--bg-700, rgba(255, 255, 255, 0.03));
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
  border-radius: 4px;
}
.dp-sig-chain__cert--leaf {
  border-color: var(--color-success, #4caf50);
}
.dp-sig-chain__k {
  color: var(--text-tertiary);
  text-transform: uppercase;
  font-size: calc(var(--policy-font-size) - 2px);
  letter-spacing: 0.4px;
  align-self: center;
}
.dp-sig-chain__v,
.dp-sig-chain__copy {
  font-family: "Consolas", "Cascadia Code", ui-monospace, monospace;
  word-break: break-all;
  min-width: 0;
}
.dp-sig-chain__copy {
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
  padding: 0;
  font-size: inherit;
  text-align: left;
}
.dp-sig-chain__copy:hover { color: var(--color-secondary, #9ecbff); }
.dp-sig-chain__copy.is-copied { color: var(--color-success, #4caf50); }

/* ── Detection tab ──────────────────────────────────────── */
.dp-detection-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-bottom: var(--space-sm);
  align-items: center;
}

/* Rule selector strip shown when an app has multiple detection methods */
.dp-rule-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border);
}
.dp-rule-tabs__label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  align-self: center;
  margin-right: 4px;
}
.dp-rule-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.dp-rule-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--color-tertiary);
}
.dp-rule-tab.is-active {
  background: color-mix(in srgb, var(--color-primary) 18%, var(--bg-700));
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.dp-rule-tab:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.dp-rule-tab__num {
  font-size: 10px;
  color: var(--text-tertiary);
  font-weight: 700;
}
.dp-rule-tab.is-active .dp-rule-tab__num { color: var(--color-primary); }

.dp-detection-script {
  background: var(--bg-900);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: var(--space-sm) var(--space-md);
  font-family: "Cascadia Code", "Consolas", "Fira Code", ui-monospace, monospace;
  font-size: var(--policy-font-size);
  color: var(--text-primary);
  white-space: pre;
  overflow: auto;
  max-height: 100%;
  line-height: 1.5;
}
.dp-detection-script::-webkit-scrollbar       { width: 8px; height: 8px; }
.dp-detection-script::-webkit-scrollbar-track { background: var(--bg-800); }
.dp-detection-script::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.dp-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.dp-copy-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--color-tertiary);
}
.dp-copy-btn.is-copied { color: var(--color-success); border-color: var(--color-success); }

.dp-fk--with-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.dp-program__copy-cmd {
  text-transform: none;
  letter-spacing: 0;
}

/* ── Dependencies tab ───────────────────────────────────── */
.dp-deps-summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: var(--space-sm);
  font-size: 11px;
  color: var(--text-tertiary);
}
.dp-deps-summary__count {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.2px;
}
.dp-deps-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--policy-font-size);
  font-family: var(--policy-font-family);
}
.dp-deps-table th,
.dp-deps-table td {
  text-align: left;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.dp-deps-table th {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  background: var(--bg-800);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.dp-deps-table tr:last-child td { border-bottom: none; }
.dp-deps-table td.dp-deps-table__num { text-align: right; color: var(--text-secondary); width: 1%; white-space: nowrap; }
.dp-deps-table td.dp-deps-table__level { text-align: center; color: var(--text-secondary); width: 1%; white-space: nowrap; }
.dp-dep-name { font-weight: 600; color: var(--text-primary); }
.dp-dep-name--missing { color: var(--text-tertiary); font-style: italic; font-weight: 400; }
.dp-dep-id {
  display: block;
  margin-top: 1px;
  font-family: "Consolas", "Cascadia Code", ui-monospace, monospace;
  color: var(--text-tertiary);
  font-size: calc(var(--policy-font-size) - 1px);
}
.dp-dep-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}
.dp-dep-badge--dependency  { background: color-mix(in srgb, var(--color-primary) 18%, var(--bg-700));   color: var(--color-primary); }
.dp-dep-badge--supersedes  { background: color-mix(in srgb, var(--color-warning) 18%, var(--bg-700));   color: var(--color-warning); }
.dp-dep-badge--detect      { background: color-mix(in srgb, var(--color-secondary) 18%, var(--bg-700)); color: var(--color-secondary); }
.dp-dep-badge--install     { background: color-mix(in srgb, var(--color-success) 14%, var(--bg-700));   color: var(--color-success); }
.dp-dep-badge--uninstall   { background: color-mix(in srgb, var(--color-error)  14%, var(--bg-700));    color: var(--color-error);  }
.dp-dep-badge--update      { background: color-mix(in srgb, var(--color-secondary) 18%, var(--bg-700)); color: var(--color-secondary); }
.dp-dep-badge--replace     { background: color-mix(in srgb, var(--color-warning) 18%, var(--bg-700));   color: var(--color-warning); }
.dp-dep-badge--unknown     { background: var(--bg-700); color: var(--text-secondary); }

/* Resolved chain (transitive walk over per-app FlatDependencies) */
.dp-dep-chain {
  margin-top: var(--space-md);
  border-top: 1px dashed var(--border);
  padding-top: var(--space-sm);
}
.dp-dep-chain summary {
  cursor: pointer;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 0;
  -webkit-user-select: none;
  user-select: none;
}
.dp-dep-chain summary:hover { color: var(--text-secondary); }
.dp-dep-chain__hint {
  margin: 4px 0 8px;
  font-size: 11px;
  color: var(--text-tertiary);
}
.dp-dep-chain__list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
}
.dp-dep-chain__list .dp-dep-chain__list {
  margin: 4px 0 0 8px;
  padding-left: 14px;
  border-left: 1px solid var(--border);
}
.dp-dep-chain__node { padding: 3px 0; }
.dp-dep-chain__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: var(--policy-font-size);
  font-family: var(--policy-font-family);
}
.dp-dep-chain__row .dp-dep-id { display: inline; margin-top: 0; }
.dp-dep-chain__cycle {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 700;
  color: var(--color-warning);
  padding: 1px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-warning) 14%, var(--bg-700));
}
.dp-dep-chain__truncated {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--color-warning);
}

/* ── Return Codes tab ───────────────────────────────────── */
/* Reuses .dp-deps-table layout; only the type-badge colors change. */
.dp-rc-badge--success     { background: color-mix(in srgb, var(--color-success)   14%, var(--bg-700)); color: var(--color-success);   }
.dp-rc-badge--soft-reboot { background: color-mix(in srgb, var(--color-secondary) 18%, var(--bg-700)); color: var(--color-secondary); }
.dp-rc-badge--hard-reboot { background: color-mix(in srgb, var(--color-warning)   18%, var(--bg-700)); color: var(--color-warning);   }
.dp-rc-badge--retry       { background: color-mix(in srgb, var(--color-tertiary)  18%, var(--bg-700)); color: var(--color-tertiary);  }
.dp-rc-badge--failure     { background: color-mix(in srgb, var(--color-error)     14%, var(--bg-700)); color: var(--color-error);     }
.dp-rc-code {
  font-family: "Consolas", "Cascadia Code", ui-monospace, monospace;
  font-weight: 600;
  color: var(--text-primary);
}
.dp-rc-code-hex {
  margin-left: 8px;
  color: var(--text-tertiary);
  font-family: "Consolas", "Cascadia Code", ui-monospace, monospace;
  font-weight: 400;
  font-size: calc(var(--policy-font-size) - 1px);
}
/* Highlight the selected row in the policy table */
.policy-table tbody tr.is-selected td { background: color-mix(in srgb, var(--color-secondary) 14%, var(--bg-800)); }
.policy-table tbody tr.is-selected:hover td { background: color-mix(in srgb, var(--color-secondary) 22%, var(--bg-800)); }
.policy-table tbody tr { cursor: pointer; }

/* ── Modal (shared: dim + blur backdrop, centered card) ─── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: min(15vh, 120px) 16px 16px;
  animation: modal-fade-in 0.12s ease-out;
}
.modal-backdrop[hidden] { display: none !important; }

@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal {
  background: var(--bg-800);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-width: 260px;
  max-width: min(540px, 90vw);
  width: max-content;
  /* Keep the modal within the backdrop's content area (its top padding + 16px bottom).
     dvh accounts for mobile browser chrome; vh is the fallback. */
  max-height: calc(100vh - min(15vh, 120px) - 16px);
  max-height: calc(100dvh - min(15vh, 120px) - 16px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-pop 0.14s ease-out;
}
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 8px 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal__title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--text-primary);
  margin: 0;
}
.modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.modal__close:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal__close:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }
.modal__body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  min-height: 0;
  overscroll-behavior: contain;
}
.modal__footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Settings modal sections ────────────────────────────── */
.modal__section + .modal__section {
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border);
}
.modal__section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--space-md) 0;
  letter-spacing: 0.2px;
}

/* ── Columns picker ─────────────────────────────────────── */
.cols-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cols-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  white-space: nowrap;
}
.cols-item input[type="checkbox"] {
  accent-color: var(--color-primary);
  cursor: pointer;
}
.policy-table th[draggable="true"] { cursor: grab; }
.policy-table th[draggable="true"]:hover { color: var(--text-primary); }
.policy-table th.col-dragging { opacity: 0.35; }
.policy-table th.col-drag-over { border-bottom: 2px solid var(--color-primary); }

/* ── Font / Row-height toolbar button ───────────────────── */
.font-btn-wrap { position: relative; flex-shrink: 0; }
.font-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.font-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--color-tertiary);
}
.font-btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.font-popover__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.font-popover__label--mt { margin-top: 10px; }
.font-stepper {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-700);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.font-size-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 28px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.font-size-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.font-size-btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }
.font-size-btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.font-size-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 28px;
  text-align: center;
  -webkit-user-select: none;
  user-select: none;
}
.font-family-select {
  width: 100%;
  background: var(--bg-700);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 11px;
  padding: 4px 6px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.12s;
}
.font-family-select:focus { border-color: var(--color-primary); }

/* ── Filter input (toolbar) ─────────────────────────────── */
.filter-btn-wrap { position: relative; flex-shrink: 0; }
.filter-btn { position: relative; }
.filter-btn--active {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.filter-btn__badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--color-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  box-sizing: border-box;
  pointer-events: none;
}
.filter-btn__badge[hidden] { display: none; }

.filter-wrap {
  flex: 1;
  min-width: 140px;
  max-width: 380px;
  position: relative;
}
.filter-input {
  width: 100%;
  background: var(--bg-700);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12px;
  padding: 6px 10px;
  outline: none;
  transition: border-color 0.12s;
}
.filter-input::placeholder { color: var(--text-tertiary); }
.filter-input:focus { border-color: var(--color-primary); }

/* ── Hidden file input ──────────────────────────────────── */
#file-input { display: none; }

/* ── Overflow menu action buttons (mobile) ────────────── */
.overflow-btn-wrap { position: relative; flex-shrink: 0; }
.actions-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.actions-btn + .actions-btn { margin-top: 6px; }
.actions-btn:hover {
  background: var(--bg-hover);
  border-color: var(--color-tertiary);
}
.actions-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.actions-btn svg { flex-shrink: 0; color: var(--text-secondary); }
.actions-btn--danger:hover {
  border-color: #b91c1c;
  color: #fecaca;
}
.actions-btn--danger:hover svg { color: #fecaca; }

/* ── Mobile-only filter search inside Filters modal ───── */
.filters-search { margin-bottom: var(--space-md); }
.filters-search .filter-input { width: 100%; box-sizing: border-box; }

/* ── Responsive utilities ─────────────────────────────── */
/* Two-tier progressive collapse:
     md-down (≤ 720px) — filter textbox collapses into the Filters modal.
     sm-down (≤ 480px) — Open/Paste/Clear buttons collapse into the kebab "Actions" menu.
   Both tiers keep the header on a single row. */
.show-md-down { display: none !important; }
.show-sm-down { display: none !important; }

@media (max-width: 720px) {
  .hide-md-down { display: none !important; }
  .show-md-down { display: revert !important; }
  .app-header {
    flex-wrap: nowrap;
    gap: 6px;
    padding: var(--space-sm) var(--space-md);
  }
  .brand__title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .toolbar-divider { height: 20px; }
}

@media (max-width: 480px) {
  .hide-sm-down { display: none !important; }
  .show-sm-down { display: revert !important; }
}
