:root {
  /* Lock native form controls to dark to reduce OS-level variability */
  color-scheme: dark;

  --bg: #0b0f14;
  --panel: rgba(255, 255, 255, 0.05);
  --panel-2: rgba(255, 255, 255, 0.08);
  --text: #e8eef7;
  --muted: #93a4b3;
  --line: rgba(255, 255, 255, 0.12);

  /* orbit-ish brand gradient: cyan → violet */
  --brand: #7dd3fc;
  --brand-2: #a855f7;

  --good: #22c55e;
  --bad: #ef4444;
  --warn: #f59e0b;

  --chip: rgba(255, 255, 255, 0.12);
  --chip-t: #c9d6e3;

  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

/* Prevent iOS Safari from randomly zooming text */
html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color: var(--text);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  background: radial-gradient(
      1200px 800px at -10% -10%,
      #132030,
      transparent 60%
    ),
    radial-gradient(1400px 900px at 110% -10%, #1a2a40, transparent 60%),
    radial-gradient(1400px 1000px at 50% 120%, #0f1a27, transparent 60%),
    var(--bg);
}

img {
  max-width: 100%;
  height: auto;
}

/* ===================== Top Bar & Header ===================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.15));
  border-bottom: 1px solid var(--line);
}

.topwrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo {
  flex: 0 0 auto;
  width: fit-content;
  max-width: min(448px, 94vw);
  display: flex;
  align-items: center;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.logo img {
  height: 77px;
  width: auto;
  max-width: none;
  display: block;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.subtitle {
  font-size: 11px;
  color: var(--muted);
  opacity: 0.9;
}

.who {
  color: var(--muted);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid var(--line);
}

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

#btnMobileNav {
  display: none;
}

/* ===================== Buttons ===================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: 0.16s background, 0.16s transform, 0.16s box-shadow,
    0.16s border-color;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.btn i {
  margin-right: 6px;
  font-size: 0.9em;
}

.btn.icon-only {
  padding: 6px 8px;
}

.btn.icon-only i {
  margin-right: 0;
}

.btn .btn-label {
  vertical-align: middle;
}

.btn:hover {
  transform: translateY(-1px);
  background: var(--panel-2);
}

.btn:active {
  transform: translateY(0);
}

/* Ghost variant */
.btn.ghost {
  background: transparent;
  border-color: rgba(148, 163, 184, 0.7);
}

.btn.ghost:hover {
  background: rgba(148, 163, 184, 0.14);
  border-color: rgba(148, 163, 184, 0.95);
}

/* Filled variants */
.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent;
}

.btn.primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.35);
}

.btn.primary:active {
  filter: brightness(1) saturate(1.1);
}

.btn.danger {
  color: #fff;
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  border-color: transparent;
}

.btn.danger:hover {
  filter: brightness(1.06);
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.35);
}

.btn.danger:active {
  filter: brightness(0.98) saturate(1.1);
}

.btn.sm {
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
}

/* Keep action buttons on one line in tables */
.actions-cell {
  white-space: nowrap;
}

.actions-cell .btn {
  white-space: nowrap;
}

/* Optional: dedicated config backup cell */
.agents-table .config-backup-cell {
  white-space: nowrap;
}

/* Icon color states for config backups */
.config-ok {
  color: var(--good);
}

.config-warn {
  color: var(--warn);
}

.config-bad {
  color: var(--bad);
}

/* ===================== Nav / Shell / Cards ===================== */

.subnav {
  display: flex;
  gap: 8px;
}

.subnav .tab {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
  white-space: nowrap;
  transition: 0.18s background, 0.18s transform, 0.18s box-shadow;
}

.subnav .tab .tab-label {
  display: none;
}

.subnav .mobile-menu-extra {
  display: none;
}

.subnav .tab:hover {
  background: var(--panel-2);
  transform: translateY(-1px);
}

.subnav .tab:active {
  transform: translateY(0);
  background: rgba(255, 255, 255, 0.12);
}

.subnav .tab.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent;
  color: #fff;
}

.shell {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 18px;
  display: none;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.06),
    rgba(255, 255, 255, 0.02)
  );
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

h2,
h3 {
  margin: 0 0 10px;
}

.help {
  font-size: 12px;
  color: var(--muted);
}

/* ===================== Card header / titles ===================== */
/* Generic card heading block used by Ops and Users pages. Two-up layout
   with optional action area on the right; stacks on phones. */

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: 0.1px;
}

.card-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.45;
}

/* ===================== Field wrapper ===================== */
/* The app uses .field as a small vertical group of label+input (used in
   agent filters, ops forms, report filters, etc.). No base styles were
   defined before so widths were erratic across screens. */

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 180px;
  min-width: 0;
}

.field > label {
  margin: 0 0 2px;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.2px;
}

.field > input,
.field > select,
.field > textarea {
  padding: 8px 10px;
  font-size: 13px;
}

/* ===================== Form Elements ===================== */

label {
  display: block;
  margin: 10px 0 6px;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  outline: none;
  transition: 0.15s border, 0.15s background;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  background: rgba(255, 255, 255, 0.05);
}

textarea {
  resize: vertical;
  min-height: 140px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono",
    monospace;
}

/* ---- Select hardening (prevents “white dropdown” on some Windows/Chromium) ---- */
select {
  /* Ensure UA widgets follow dark theme */
  color-scheme: dark;

  /* Keep same base styling as other inputs */
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border: 1px solid var(--line);

  /* Remove OS styling; we provide our own caret */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;

  /* Space for custom caret */
  padding-right: 34px;

  /* Custom caret (two small triangles) */
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 55%,
    calc(100% - 12px) 55%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

select:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
}

select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Best-effort styling for dropdown list (OS may still override on some endpoints) */
select option {
  background: var(--bg);
  color: var(--text);
}

/* Forced colors / high contrast compatibility */
@media (forced-colors: active) {
  select {
    /* Let the OS pick accessible colors; ensure border remains visible */
    border: 1px solid ButtonText;
    background-image: none;
  }
}

/* ===================== Tables ===================== */

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 10pt;
}

.reports-table {
  font-size: 8.75pt;
}

.reports-table thead th,
.reports-table td {
  font-size: 8.75pt;
  padding: 8px 9px;
  line-height: 1.15;
}

.reports-table thead th {
  white-space: nowrap;
}

.reports-table .report-nowrap-cell {
  white-space: nowrap;
}

.reports-table .report-wrap-cell {
  white-space: normal;
  overflow-wrap: anywhere;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 10pt;
  letter-spacing: 0.2px;
  border-bottom: 1px solid var(--line);
  cursor: default;
}

th,
td {
  padding: 12px;
  font-size: 10pt;
}

tbody tr {
  border-bottom: 1px solid var(--line);
  transition: 0.15s background;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--chip-t);
  border: 1px solid var(--line);
}

/* Status chips for Agents filter */
.chip-status {
  font-weight: 500;
}

/* Visually highlight the active status chip */
.chip.chip-active {
  background: rgba(125, 211, 252, 0.14); /* soft cyan */
  border-color: var(--brand);
  color: var(--text);
}

.alarm-chip {
  font-weight: 600;
}

.alarm-chip-on {
  border-color: var(--warn);
  background: rgba(245, 158, 11, 0.18);
}

.alarm-chip-off {
  border-color: var(--line);
  opacity: 0.85;
}

/* Modal body typography */
.modal-body {
  font-size: 13px;
  color: var(--text);
}

.modal-body .help {
  font-size: 12px;
  color: var(--muted);
}

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

.sticky-controls {
  position: sticky;
  top: 84px;
  z-index: 5;
  padding: 8px 0;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0));
  border-bottom: 1px solid transparent;
}

.page-toolbar {
  padding: 10px 12px;
  margin: -2px -4px 10px;
  border-radius: 12px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0.03)
  );
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
  }

.page-toolbar > .row:first-child {
  gap: 8px;
}

.page-toolbar h2 {
  margin-right: 6px;
}

.toolbar-meta {
  margin-left: auto;
  gap: 8px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  flex: 0 0 auto;
}

.toolbar-meta label {
  display: inline-block;
  margin: 0;
  white-space: nowrap;
}

.toolbar-meta .help {
  margin: 0;
  white-space: nowrap;
}

.toolbar-meta select {
  width: auto;
  min-width: 84px;
  flex: 0 0 auto;
}

/* ===================== Users & Permissions ===================== */

.user-list {
  max-height: 480px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.user-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.user-item.active {
  background: rgba(59, 130, 246, 0.15);
  border-left: 3px solid var(--brand-2);
}

.perm-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(200px, 1fr));
  gap: 10px 16px;
  margin: 6px 0 6px;
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 12px 18px;
  margin: 8px 0 6px;
}

.ops-card {
  border-radius: 18px;
}

.ops-card .card-header {
  margin-bottom: 4px;
}

.ops-subtabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.ops-subtab {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.ops-subtab.active {
  background: linear-gradient(135deg, rgba(66, 153, 225, 0.32), rgba(59, 130, 246, 0.18));
  border-color: rgba(96, 165, 250, 0.45);
  color: #f8fbff;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.16);
}

.ops-actions {
  margin-top: 12px;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.checkbox-field {
  display: flex;
  align-items: center;
  min-height: 42px;
}

.checkbox-field label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  line-height: 1.35;
}

.checkbox-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: 0 0 auto;
}

.email-rule-section {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(15, 23, 42, 0.22);
}

.email-rule-section-title {
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: 0.01em;
}

.email-rule-tight-grid {
  margin-top: 0;
}

.email-rule-compact-field {
  max-width: 180px;
}

.email-rule-two-up {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 8px;
}

.email-rule-controls-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.email-rule-controls-stack .field {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  max-width: 180px;
}

.email-rule-controls-stack .checkbox-field {
  min-height: 0;
  max-width: none;
}

.email-rule-controls-stack .field > input,
.email-rule-controls-stack .field > select {
  width: 160px;
}

.mailbox-oauth-field {
  display: none;
}

.mailbox-imap-field {
  display: block;
}

#emailAlertEventsTable table {
  table-layout: fixed;
  width: 100%;
  min-width: 0;
  font-size: 12px;
}

#emailAlertEventsTable th,
#emailAlertEventsTable td {
  white-space: nowrap;
  vertical-align: middle;
  font-size: 12px;
  line-height: 1.2;
}

#emailAlertEventsTable th .help,
#emailAlertEventsTable td.help {
  font-size: 11px;
}

#emailAlertEventsTable td.email-alert-received {
  width: 150px;
  min-width: 150px;
  max-width: 150px;
  overflow: visible;
  text-overflow: clip;
}

#emailAlertEventsTable td.email-alert-customer-site {
  width: 160px;
  min-width: 160px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#emailAlertEventsTable .email-alert-customer-site-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#emailAlertEventsTable td.email-alert-device {
  width: 72px;
  min-width: 72px;
  max-width: 72px;
  overflow: visible;
  text-overflow: clip;
}

#emailAlertEventsTable td.email-alert-match {
  width: 56px;
  max-width: 56px;
  text-align: center;
}

#emailAlertEventsTable td.email-alert-error {
  width: auto;
  overflow: hidden;
  text-overflow: ellipsis;
}

#emailAlertEventsTable .email-alert-truncate {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#emailAlertEventsTable td.email-alert-actions,
#emailAlertEventsTable td.email-alert-row-actions {
  white-space: nowrap;
}

#emailAlertEventsTable td.email-alert-actions {
  width: 60px;
  max-width: 60px;
  min-width: 60px;
}

#emailAlertEventsTable td.email-alert-row-actions {
  width: 26px;
  max-width: 26px;
  min-width: 26px;
}

#emailAlertEventsTable td.email-alert-row-actions .row {
  flex-wrap: nowrap;
  gap: 4px !important;
}

#emailAlertEventsTable .email-alert-actions-icons {
  display: inline-flex;
  align-items: center;
  gap: 0;
  white-space: nowrap;
  overflow: visible;
}

#emailAlertEventsTable .email-alert-match-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

#emailAlertEventsTable .btn.icon-only {
  padding: 5px 6px;
}

#emailAlertEventsTable td.email-alert-actions .btn.icon-only,
#emailAlertEventsTable td.email-alert-row-actions .btn.icon-only {
  padding: 1px 2px;
  min-width: 18px;
  min-height: 18px;
  border-width: 0;
  background: transparent;
}

#alertMailboxSettingsCard.graph-provider .mailbox-imap-field {
  display: none !important;
}

#alertMailboxSettingsCard.graph-provider .mailbox-oauth-field {
  display: block !important;
}

#alertMailboxSettingsCard.graph-provider #es_alertMailboxPassWrap {
  display: none !important;
}

#alertMailboxSettingsCard.imap-provider.password-auth .mailbox-oauth-field {
  display: none !important;
}

#alertMailboxSettingsCard.imap-provider.oauth-auth .mailbox-oauth-field {
  display: block !important;
}

#alertMailboxSettingsCard.imap-provider.oauth-auth #es_alertMailboxPassWrap {
  display: none !important;
}

.perm-item {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.perm-item input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.perm-item label {
  margin: 0;
  font-size: 14px;
}

/* ===================== Misc Helpers ===================== */

.hidden {
  display: none !important;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12) inset;
}

.dot.ok {
  background: var(--good); /* Online */
}

.dot.bad {
  background: var(--bad); /* Offline */
}

.dot.inactive {
  background: #6b7280; /* neutral gray for inactive */
}

.dot.warn {
  background: var(--warn); /* Alarm */
}
.hb-icons {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 10px;
}

.hb-icon {
  font-size: 14px;
  opacity: 0.95;
}

.hb-icon.ok {
  color: var(--good);
}

.hb-icon.bad {
  color: var(--bad);
}

.hb-icon.warn {
  color: var(--warn);
}

.hb-icon.unknown {
  color: #6b7280;
}

.status-filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: center;
}

.status-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.status-toggle input[type="checkbox"] {
  margin: 0;
}

.caret {
  opacity: 0.6;
  font-size: 11px;
  margin-left: 6px;
}

.th-sort {
  cursor: pointer;
}

.mini-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(0, 0, 0, 0.25);
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.mini-table th,
.mini-table td {
  padding: 8px 10px;
}

.mini-table tbody tr {
  border-bottom: 1px solid var(--line);
}

.mini-pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.mono {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono",
    monospace;
}

/* GUID badge */

.badge-guid {
  display: inline-block;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1;
  letter-spacing: 0.01em;
  padding: 0.25rem 0.35rem;
  margin-top: 0.25rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  opacity: 0.9;
  user-select: all;
}

/* ===================== Agent Modal Layout ===================== */

.agent-modal {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Three-column meta grid on desktop */
.agent-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.agent-meta-card {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.7);
  padding: 10px 12px;
}

.agent-meta-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}

.agent-meta-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.agent-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 13px;
}

.agent-meta-row strong {
  min-width: 100px;
}

/* Buttons row under identity card */
.agent-meta-actions {
  margin-top: 8px;
  justify-content: flex-start;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.history-table th,
.history-table td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
}

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}

.bar-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.bar-label {
  flex: 0 0 130px;
  color: var(--muted);
  white-space: nowrap;
}

.bar-track {
  position: relative;
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  padding: 2px;
}

.bar-fill {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
}

.bar-value {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text);
}

.history-toggle .chip {
  cursor: pointer;
}

.history-toggle .chip-active {
  background: var(--brand);
  color: #000;
}

/* History toolbar (view toggle + page size) */
.agent-history-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.agent-history-toggle {
  flex-wrap: wrap;
}

.agent-history-page {
  align-items: center;
}

/* History table + pager spacing */
.agent-history-table {
  margin-top: 8px;
}

.agent-history-pager {
  justify-content: space-between;
  margin-top: 8px;
}

/* Semantic chip colors */
.chip-ok {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.4);
  color: #bbf7d0;
}

.chip-warn {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.45);
  color: #fed7aa;
}

.chip-bad {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fecaca;
}

.severity-shield {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.2;
  text-transform: capitalize;
}

.severity-shield.sev-critical {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.5);
}

.severity-shield.sev-high {
  color: #fca5a5;
  background: rgba(248, 113, 113, 0.14);
  border-color: rgba(248, 113, 113, 0.45);
}

.severity-shield.sev-medium {
  color: #fed7aa;
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.5);
}

.severity-shield.sev-low {
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.45);
}

.severity-shield.sev-unknown {
  color: var(--muted);
  background: rgba(148, 163, 184, 0.1);
  border-color: rgba(148, 163, 184, 0.4);
}

/* ===================== Legacy mobile shims ===================== */
/* Rules that are NOT covered by the consolidated mobile block further
   down in the file. Everything else has been moved to the unified
   "Full interface cleanup — phone layer" section at the bottom. */

@media (max-width: 768px) {
  .badge-guid {
    max-width: 100%;
    overflow-wrap: anywhere;
  }
}

/* ===================== Agent Modal Responsive ===================== */

@media (max-width: 1024px) {
  .agent-meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .agent-meta-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .agent-meta-row strong {
    min-width: 0;
  }
}

.signal-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  vertical-align: baseline;
}

.signal-bar {
  width: 3px;
  border-radius: 2px;
  opacity: 0.4;
  background: var(--line, rgba(255, 255, 255, 0.3));
}

.signal-bar.on {
  opacity: 1;
  background: var(--good, #22c55e);
}

/* Make them increasing heights: 25%, 50%, 75%, 100% */
.signal-bar:nth-child(1) {
  height: 4px;
}
.signal-bar:nth-child(2) {
  height: 7px;
}
.signal-bar:nth-child(3) {
  height: 10px;
}
.signal-bar:nth-child(4) {
  height: 13px;
}

.rssi-pill{
  display:inline-block;
  padding:2px 8px;
  border-radius:999px;
  font-size:12px;
  font-weight:600;
  border:1px solid transparent;
}

.rssi-excellent{ background:#e7f7ee; color:#0b6b2e; border-color:#bfe9cf; }
.rssi-good     { background:#eef8e6; color:#2f6b0b; border-color:#d8efc6; }
.rssi-fair     { background:#fff4e5; color:#8a5a00; border-color:#ffe0b2; }
.rssi-poor     { background:#ffecec; color:#8a0f0f; border-color:#ffc5c5; }
.rssi-unknown  { background:#f2f2f2; color:#555;    border-color:#e2e2e2; }

.row { display:flex; align-items:center; }
.wrap { flex-wrap: wrap; }
.gap-1 { gap: .4rem; }
.gap-2 { gap: .7rem; }
.stack { display:flex; flex-direction: column; }
.input.sm { height: 30px; padding: 4px 8px; }

/* Small status icons used in Agents table (BeyondTrust, Power, etc.) */
.icon-status {
  font-size: 14px;
  vertical-align: middle;
}
.icon-status.ok { color: var(--good); }
.icon-status.bad { color: var(--bad); }
.icon-status.warn { color: var(--warn); }
.icon-status.muted { color: rgba(255, 255, 255, 0.45); }

.agentTopGrid{
  display:grid;
  grid-template-columns: 1.35fr 1fr;
  gap:12px;
  align-items:start;
}
.agentTopRight{
  display:grid;
  grid-template-columns: 1fr;
  gap:12px;
}
@media (max-width: 980px){
  .agentTopGrid{ grid-template-columns: 1fr; }
}

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

.details summary{
  cursor:pointer;
  font-weight:600;
  user-select:none;
}
.details{ margin-top:10px; }

/* ===================== Security tool groups ===================== */
/* Used by renderAgentSecurityCard. Four categorized panels of buttons
   (Detection / Repair / Response / Offense-Defense) with live finding
   chips underneath each module button. Must collapse cleanly on phones. */

.sec-panel {
  margin-top: 10px;
}

.sec-panel-header {
  font-size: 12px;
  line-height: 1.4;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sec-panel-header .sec-open-count {
  font-weight: 700;
  font-size: 14px;
}

.sec-toolgroups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
}

.sec-group {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.sec-group[data-kind="detection"] {
  background: rgba(80, 160, 255, 0.06);
  border-color: rgba(80, 160, 255, 0.25);
}
.sec-group[data-kind="repair"] {
  background: rgba(80, 200, 120, 0.06);
  border-color: rgba(80, 200, 120, 0.28);
}
.sec-group[data-kind="response"] {
  background: rgba(255, 180, 60, 0.07);
  border-color: rgba(255, 180, 60, 0.3);
}
.sec-group[data-kind="offdef"] {
  background: rgba(200, 120, 255, 0.07);
  border-color: rgba(200, 120, 255, 0.3);
}

.sec-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
}

.sec-group-title .sec-group-tag {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.sec-group-desc {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted, rgba(255, 255, 255, 0.65));
  margin: 0;
}

.sec-group-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
  align-items: flex-start;
}

.sec-tool {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  flex: 0 1 auto;
}

.sec-tool .btn.sm {
  white-space: normal;
  text-align: left;
  line-height: 1.25;
  min-height: 32px;
}

.sec-tool-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  min-height: 18px;
}

.sec-tool-chips .chip {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 999px;
  line-height: 1.5;
}

.sec-tool-chips .chip.chip-empty {
  opacity: 0.55;
}

/* Mobile layout: single column, full-width buttons, chip rows centered
   and easy to tap. Tuned so the agent modal on a phone is actually usable. */
@media (max-width: 768px) {
  .sec-panel-header {
    font-size: 13px;
    padding: 8px 10px;
  }

  .sec-toolgroups {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .sec-group {
    padding: 12px;
    border-radius: 12px;
  }

  .sec-group-title {
    font-size: 15px;
  }

  .sec-group-desc {
    font-size: 12.5px;
  }

  .sec-group-btns {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .sec-tool {
    width: 100%;
    align-items: stretch;
  }

  .sec-tool .btn.sm,
  .sec-group-btns > .btn.sm {
    width: 100%;
    min-height: 44px;
    font-size: 14px;
    padding: 10px 12px;
    text-align: center;
  }

  .sec-group-btns > .btn.sm .btn-label,
  .sec-tool .btn.sm .btn-label {
    white-space: normal;
  }

  .sec-tool-chips {
    justify-content: flex-start;
    padding-left: 2px;
  }

  .sec-tool-chips .chip {
    font-size: 11px;
    padding: 2px 8px;
  }

  /* Make the card header toolbar behave — "Run full assessment" should be
     full-width and easy to hit with a thumb. */
  .card-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .card-head > div:first-child {
    min-width: 0;
  }
  .card-actions {
    width: 100%;
    justify-content: stretch;
  }
  .card-actions > .btn.sm.primary {
    flex: 1 1 auto;
    min-height: 44px;
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .sec-panel-header .sec-open-count {
    font-size: 16px;
  }
}

/* ===================== Modal on phones ===================== */
/* The app's main modal is inline-styled for desktop (min(900px, 92vw),
   max-height 82vh). On phones we want it nearly fullscreen with tighter
   padding so the content actually fits. */

@media (max-width: 768px) {
  #modalWrap {
    padding: 0 !important;
    align-items: stretch !important;
  }

  #modalWrap > .modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 100vh !important;
    height: 100vh !important;
    border-radius: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
    border-top: 0 !important;
    overflow: auto !important;
    display: flex;
    flex-direction: column;
  }

  #modalWrap > .modal > header {
    padding: 12px 14px !important;
    flex: 0 0 auto;
  }

  #modalWrap > .modal > header h3 {
    font-size: 15px;
    line-height: 1.2;
  }

  #modalWrap > .modal > section {
    padding: 12px !important;
    flex: 1 1 auto;
  }

  #modalBody {
    padding: 10px !important;
    border-radius: 10px !important;
  }

  /* Any inner "row" of action chips / buttons inside the modal should wrap */
  #modalBody .row {
    gap: 8px;
    flex-wrap: wrap;
  }

  /* Tables inside the modal get a horizontal scroller instead of crushing */
  #modalBody table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
}

/* ===================== General phone polish ===================== */
/* Small touch-ups that apply across the app, not just the security card. */

@media (max-width: 768px) {
  /* Primary buttons in the top app bar and page toolbars are easier to tap. */
  .btn {
    min-height: 38px;
  }
  .btn.sm {
    min-height: 34px;
  }

  /* Page toolbars stack nicely */
  .page-toolbar {
    padding: 10px;
    margin: -2px 0 10px;
  }
  .page-toolbar .row {
    flex-wrap: wrap;
    gap: 8px;
  }
  .toolbar-meta {
    margin-left: 0;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px;
  }

  /* Sticky controls can clip the first card on small screens — lighten it. */
  .sticky-controls {
    position: static;
    padding: 4px 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: transparent;
  }

  /* Hide redundant button labels where the icon alone communicates the action.
     Only applies to buttons that explicitly opt in via .btn-icon-only-mobile. */
  .btn-icon-only-mobile .btn-label {
    display: none;
  }
}

/* =====================================================================
   Full interface cleanup — phone layer
   ---------------------------------------------------------------------
   This block is the single source of truth for how the whole app
   reflows on small screens. Earlier rules in the file provide partial
   mobile support; these rules refine and unify that behaviour so every
   page (agents, jobs, scripts, ops, reports, users, workspace, email
   alerts, agent modal) renders correctly from ~320px up.
   ===================================================================== */

@media (max-width: 768px) {
  /* --- Body / shell --------------------------------------------- */
  body {
    /* Prevent horizontal scroll from inline max-width tricks */
    overflow-x: hidden;
  }

  .shell {
    padding: 0 10px;
    margin: 10px auto 24px;
  }

  .stack {
    gap: 10px;
  }

  .card {
    padding: 12px;
    border-radius: 12px;
  }

  /* --- Top bar (logo + rightbar + subnav) ----------------------- */
  .topwrap {
    padding: 10px 12px;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
  }

  .brand {
    flex: 1 1 auto;
    gap: 10px;
    min-width: 0;
  }

  .logo {
    max-width: min(384px, 96vw);
  }

  .logo img {
    height: 64px;
  }

  .who {
    display: none;
  }

  .rightbar {
    flex: 0 0 auto;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .rightbar > .btn.icon-only {
    min-height: 38px;
    min-width: 38px;
    padding: 8px 10px;
  }

  /* Mobile nav becomes a hamburger-triggered dropdown. */
  #subnav {
    order: initial;
    flex: 0 0 auto;
    width: min(360px, calc(100vw - 24px));
    max-height: 65vh;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 8px;
    gap: 6px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(10, 14, 20, 0.96);
    box-shadow: var(--shadow);
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 50;
    display: none;
  }
  #subnav.mobile-open {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }
  #subnav .tab {
    width: 100%;
    justify-content: flex-start;
    padding: 10px 12px;
    min-width: 0;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
  }
  #subnav .tab .tab-label {
    display: inline;
  }
  #subnav .mobile-menu-extra {
    display: inline-flex;
  }
  #btnMobileNav {
    display: inline-flex;
  }
  .rightbar {
    position: relative;
  }

  /* --- Page toolbars (sticky refresh / export / etc.) ----------- */
  .page-toolbar {
    padding: 10px;
    margin: -2px 0 10px;
    border-radius: 12px;
  }

  .page-toolbar > .row {
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
  }

  .page-toolbar h2 {
    flex: 1 1 auto;
    font-size: 17px;
    margin: 0;
  }

  /* The "Rows" selector + meta info row goes full-width below the buttons */
  .toolbar-meta {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px;
  }
  .toolbar-meta label {
    font-size: 11px;
  }
  .toolbar-meta select {
    min-width: 72px;
    flex: 0 0 auto;
  }

  /* --- Filter rows (.field wrappers) ---------------------------- */
  /* Each field takes the full width instead of squashing side by side. */
  .field {
    flex: 1 1 100%;
    min-width: 0;
  }

  /* Inline card min-width styles used throughout desktop layouts can force horizontal scrolling. */
  .card[style*="min-width"],
  div[style*="min-width:320px"],
  div[style*="min-width:280px"] {
    min-width: 0 !important;
  }

  /* Two-up desktop card flex-basis rules should stack on phone/tablet widths. */
  .card[style*="calc(50% - 8px)"] {
    flex: 1 1 100% !important;
    width: 100% !important;
  }

  /* Inline-styled filter inputs inside Jobs/Reports/Audit toolbars
     were hard-capped at 220-260px which looked odd on phones. */
  .page-toolbar input[style*="max-width"],
  .page-toolbar select[style*="max-width"],
  .page-toolbar select[style*="min-width"] {
    max-width: 100% !important;
    width: 100%;
    min-width: 0 !important;
  }

  /* --- Status chips (filters) ----------------------------------- */
  .chip-status,
  .chip.chip-active {
    font-size: 12px;
    padding: 6px 10px;
    min-height: 30px;
  }

  /* --- Sub-tab pills (Ops / Workspace / Email alerts) ----------- */
  /* Horizontal scroller so every sub-tab is reachable with a swipe. */
  .ops-subtabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .ops-subtabs::-webkit-scrollbar {
    display: none;
  }
  .ops-subtab {
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 36px;
  }

  /* --- Ops card header stacks ----------------------------------- */
  .card-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .card-header > .row {
    justify-content: flex-start;
  }

  /* --- Forms / labels / inputs ---------------------------------- */
  /* The Create/Update Script and Schedule cards are plain flowing
     label/input pairs. Tighter spacing is friendlier on phones. */
  label {
    margin: 8px 0 4px;
  }

  input,
  select,
  textarea {
    font-size: 14px; /* prevents iOS zoom-on-focus */
    padding: 10px 12px;
  }

  textarea {
    min-height: 120px;
  }

  /* --- Tables --------------------------------------------------- */
  /* Bleed table-wrappers to card edges and allow horizontal scroll. */
  .table-wrap {
    margin-left: -12px;
    margin-right: -12px;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    -webkit-overflow-scrolling: touch;
  }
  table {
    font-size: 12px;
  }
  th,
  td {
    padding: 8px 10px;
  }
  /* Keep table headers legible even when horizontally scrolled */
  thead th {
    font-size: 11px;
  }

  /* --- Pagers --------------------------------------------------- */
  #agentsPager,
  #scriptsPager,
  #jobsPager,
  .mini-pager {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: space-between;
  }

  /* --- User list / permissions --------------------------------- */
  .user-list {
    max-height: 340px;
  }
  .user-item {
    flex-wrap: wrap;
    gap: 6px;
    align-items: flex-start;
  }
  .perm-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
  .perm-item label {
    font-size: 13px;
  }

  /* --- Ops grid (single column) -------------------------------- */
  .ops-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  /* Fields that span the full grid row on desktop still span here */
  .ops-grid > .field[style*="grid-column"] {
    grid-column: 1 / -1 !important;
  }

  /* --- Buttons / tap targets ----------------------------------- */
  .btn {
    min-height: 40px;
    padding: 9px 14px;
  }
  .btn.sm {
    min-height: 34px;
    padding: 7px 11px;
  }
  .btn.icon-only {
    padding: 8px 10px;
  }
  .btn i {
    font-size: 0.95em;
  }

  /* --- Card rows (generic button rows inside content cards) ---- */
  /* Many places use `.row` with inline `style="gap:...; flex-wrap:wrap"`.
     For rows without those inline styles we still want them to wrap. */
  .card .row,
  .stack .row,
  .ops-actions {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* --- JSON / pre blocks scroll instead of blowing out --------- */
  .jsonout,
  .admin-json,
  pre {
    overflow-x: auto;
    max-width: 100%;
    font-size: 11.5px;
  }

  /* --- Code blocks in help text -------------------------------- */
  code {
    overflow-wrap: anywhere;
  }
}

/* ---------------------------------------------------------------------
   Very small phones (<= 480px) — extra-tight spacing + ergonomic tweaks
   --------------------------------------------------------------------- */

@media (max-width: 480px) {
  .shell {
    padding: 0 8px;
    margin-top: 8px;
  }

  .card {
    padding: 10px;
  }

  .logo {
    max-width: min(320px, 98vw);
  }

  .logo img {
    height: 54px;
  }

  .page-toolbar h2 {
    font-size: 16px;
    flex: 1 1 100%;
  }

  /* Label any row-of-chips filter as full-width */
  .page-toolbar .row[style*="margin-left:auto"] {
    margin-left: 0 !important;
    width: 100%;
    justify-content: flex-start;
  }

  th,
  td {
    padding: 7px 8px;
  }
  table {
    font-size: 11.5px;
  }
}

/* ---------------------------------------------------------------------
   Tablet (769-1024px) — keep most desktop behaviour but relax some
   hard-coded widths so the app is still comfortable in portrait tablets.
   --------------------------------------------------------------------- */

@media (min-width: 769px) and (max-width: 1024px) {
  .shell,
  .topwrap {
    padding-left: 16px;
    padding-right: 16px;
  }

  .ops-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .perm-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #btnMobileNav {
    display: inline-flex;
  }

  .rightbar {
    position: relative;
  }

  #subnav {
    width: min(360px, calc(100vw - 40px));
    max-height: 65vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
    gap: 6px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(10, 14, 20, 0.96);
    box-shadow: var(--shadow);
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 50;
    display: none;
  }

  #subnav.mobile-open {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  #subnav .tab {
    width: 100%;
    justify-content: flex-start;
    min-width: 0;
  }
  #subnav .tab .tab-label {
    display: inline;
  }
  #subnav .mobile-menu-extra {
    display: inline-flex;
  }
}

/* ---------------------------------------------------------------------
   Break-glass banner + card
   --------------------------------------------------------------------- */

.bg-banner {
  position: sticky;
  top: 0;
  z-index: 19;
  background: linear-gradient(180deg, #5b1f05, #3b1302);
  color: #ffe8c6;
  border-bottom: 1px solid rgba(245, 158, 11, 0.6);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.bg-banner-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.bg-banner-inner i.fa-triangle-exclamation {
  color: #fbbf24;
  font-size: 1.05rem;
}

.bg-banner-text {
  flex: 1 1 auto;
  font-weight: 600;
  font-size: 0.95rem;
}

.bg-panel {
  border: 1px solid rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.06);
  border-radius: 10px;
  padding: 12px 14px;
}

.bg-panel.active {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.5);
}

.bg-panel .bg-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  font-size: 0.9rem;
  margin-top: 6px;
}

.bg-panel .bg-meta dt {
  opacity: 0.7;
}

.bg-panel .bg-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.bg-history-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.bg-history-row .bg-history-reason {
  opacity: 0.85;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .bg-banner-inner {
    padding: 8px 12px;
    font-size: 0.85rem;
  }
  .bg-banner-text {
    font-size: 0.85rem;
  }
  .bg-panel .bg-meta {
    grid-template-columns: 1fr;
  }
}
