/* Shared monochrome notifications. Loaded after the global palette. */
#kxcl-toast-container.kx-notice-stack {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: calc(var(--kx-notice-bottom, 16px) + var(--kx-notice-viewport-inset, 0px) + env(safe-area-inset-bottom, 0px));
  z-index: 30000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(400px, calc(100vw - 40px));
  max-height: var(--kx-notice-height, calc(100dvh - 32px));
  padding: 0;
  margin: 0;
  pointer-events: none;
  font-family: inherit;
}

.kx-notice {
  --kx-notice-accent: var(--site-text, #f4f4f5);
  box-sizing: border-box;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 44px;
  align-items: start;
  gap: 12px;
  position: relative;
  overflow: hidden;
  max-height: var(--kx-notice-item-height, 380px);
  padding: 16px 10px 18px 16px;
  border: 1px solid var(--site-border-strong, rgba(255,255,255,.18));
  border-radius: 18px;
  background: var(--site-surface, #111113);
  color: var(--site-text, #f4f4f5);
  box-shadow: 0 18px 50px rgba(0,0,0,.22), 0 2px 8px rgba(0,0,0,.08);
  pointer-events: auto;
  transform-origin: bottom right;
  animation: kx-notice-enter .3s cubic-bezier(.2,.8,.2,1) both;
}
.kx-notice--error { --kx-notice-accent: var(--site-danger, #f87171); }
.kx-notice--warning { --kx-notice-accent: var(--site-warning, #fcd34d); }
.kx-notice.is-leaving { animation: kx-notice-leave .18s ease both; pointer-events: none; }
.kx-notice-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--kx-notice-accent);
  border: 1px solid var(--site-border);
  background: var(--site-raised);
}
.kx-notice--error .kx-notice-icon { background: var(--site-danger-soft); border-color: var(--site-danger-border); }
.kx-notice--warning .kx-notice-icon { background: var(--site-warning-soft); border-color: var(--site-warning-border); }
.kx-notice-copy { min-width: 0; min-height: 0; max-height: calc(var(--kx-notice-item-height, 380px) - 34px); padding-top: 1px; overflow-y: auto; overscroll-behavior: contain; }
.kx-notice-title {
  margin: 0 0 5px;
  font-size: 12px;
  line-height: 1.45;
  letter-spacing: -.01em;
  font-weight: 750;
  color: var(--site-text);
}
.kx-notice-message {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  font-weight: 450;
  color: var(--site-muted);
  white-space: pre-line;
  overflow-wrap: anywhere;
  max-height: clamp(44px, calc(var(--kx-notice-height, 400px) - 100px), 220px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.kx-notice-close, .kx-bell-close {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  margin-top: -4px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--site-muted);
  cursor: pointer;
  transition: background .16s, color .16s;
}
.kx-notice-close:hover, .kx-bell-close:hover { background: var(--site-hover); color: var(--site-text); }
.kx-notice-close:focus-visible, .kx-bell-close:focus-visible, .kx-bell-retry:focus-visible, .kx-bell-panel a:focus-visible {
  outline: 2px solid var(--site-focus);
  outline-offset: 2px;
}
.kx-notice-progress { position: absolute; bottom: 0; left: 0; right: 0; height: 2px; background: var(--site-border); }
.kx-notice-progress > span {
  display: block;
  height: 100%;
  background: var(--kx-notice-accent);
  transform-origin: left;
  animation: kx-notice-lifetime var(--kx-notice-duration, 5000ms) linear forwards;
  animation-delay: calc(-1 * var(--kx-notice-elapsed, 0ms));
  opacity: .55;
}
.kx-notice.is-paused .kx-notice-progress > span { animation-play-state: paused; }
html[data-theme="light"] .kx-notice { box-shadow: 0 18px 50px rgba(0,0,0,.09), 0 2px 8px rgba(0,0,0,.035); }

/* The same component is used by the dashboard, applications, invoices and admin. */
html[data-theme] #sidebar-bell-btn {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  background: var(--site-raised) !important;
  color: var(--site-muted) !important;
  border: 1px solid var(--site-border) !important;
  border-radius: 12px;
}
html[data-theme] #sidebar-bell-btn:hover, html[data-theme] #sidebar-bell-btn[aria-expanded="true"] { background: var(--site-hover) !important; color: var(--site-text) !important; }
html[data-theme] #sidebar-bell-popover.kx-bell-panel {
  position: absolute;
  inset: auto auto calc(100% + 12px) 0;
  display: flex;
  flex-direction: column;
  width: min(350px, calc(100vw - 32px));
  max-height: min(500px, calc(100dvh - 200px));
  padding: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--site-border-strong) !important;
  border-radius: 20px;
  background: var(--site-surface) !important;
  color: var(--site-text) !important;
  box-shadow: var(--site-shadow);
  z-index: 16000;
  backdrop-filter: none;
  animation: kx-bell-enter .2s ease both;
}
html[data-theme] #sidebar-bell-popover.kx-bell-panel.hidden { display: none; }
.kx-bell-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 14px 16px 20px; border-bottom: 1px solid var(--site-border); }
html[data-theme] #sidebar-bell-popover .kx-bell-heading h3 { color: var(--site-text) !important; font-size: 13px; font-weight: 750; letter-spacing: -.02em; margin: 0 0 4px; }
html[data-theme] #sidebar-bell-popover .kx-bell-heading p { color: var(--site-muted) !important; font-size: 11px; line-height: 1.45; margin: 0; }
.kx-bell-close { margin-top: 0; font-size: 23px; font-weight: 400; }
.kx-bell-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px; scrollbar-width: thin; }
.kx-bell-state { min-height: 170px; padding: 24px 16px; display: flex; align-items: center; justify-content: center; text-align: center; flex-direction: column; }
.kx-bell-state-icon { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--site-border); border-radius: 16px; background: var(--site-raised); color: var(--site-text); margin-bottom: 14px; }
.kx-bell-state-icon.is-loading svg { animation: kx-bell-spin 1.4s linear infinite; }
html[data-theme] #sidebar-bell-popover .kx-bell-state-title { color: var(--site-text) !important; font-size: 13px; font-weight: 700; margin: 0 0 6px; }
html[data-theme] #sidebar-bell-popover .kx-bell-state-description { color: var(--site-muted) !important; max-width: 250px; font-size: 11px; line-height: 1.7; margin: 0; }
.kx-bell-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.kx-bell-notice { --kx-bell-accent: var(--site-text); display: flex; align-items: flex-start; gap: 11px; padding: 12px; border-radius: 12px; color: var(--site-text); text-decoration: none; transition: background .15s; }
.kx-bell-notice:hover { background: var(--site-hover); }
.kx-bell-notice--error { --kx-bell-accent: var(--site-danger); }
.kx-bell-notice--warning { --kx-bell-accent: var(--site-warning); }
.kx-bell-notice-icon { display: flex; align-items: center; justify-content: center; flex: 0 0 32px; height: 32px; border-radius: 10px; background: var(--site-raised); color: var(--kx-bell-accent); border: 1px solid var(--site-border); }
.kx-bell-notice--error .kx-bell-notice-icon { background: var(--site-danger-soft); border-color: var(--site-danger-border); }
.kx-bell-notice--warning .kx-bell-notice-icon { background: var(--site-warning-soft); border-color: var(--site-warning-border); }
.kx-bell-notice-icon svg { width: 16px; height: 16px; }
.kx-bell-notice-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; overflow-wrap: anywhere; }
.kx-bell-notice-copy > strong { font-size: 12px; line-height: 1.5; font-weight: 650; }
.kx-bell-notice-message { font-size: 11px; line-height: 1.65; color: var(--site-muted); }
.kx-bell-notice-tag { align-self: flex-start; display: inline-flex; color: var(--kx-bell-accent); background: var(--site-raised); border: 1px solid var(--site-border); border-radius: 5px; padding: 2px 5px; font-size: 9px; line-height: 1.6; font-weight: 650; }
.kx-bell-notice-arrow { font-size: 14px; color: var(--site-muted); padding-top: 2px; }
.kx-bell-footer { flex-shrink: 0; padding: 6px; border-top: 1px solid var(--site-border); }
.kx-bell-footer a { min-height: 44px; padding: 8px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--site-text); text-decoration: none; border-radius: 12px; font-size: 11px; font-weight: 650; transition: background .15s; }
.kx-bell-footer a:hover { background: var(--site-hover); }
.kx-bell-retry { min-height: 44px; margin-top: 14px; padding: 8px 14px; background: var(--site-action-bg); color: var(--site-action-text); border: 0; border-radius: 10px; font-size: 11px; font-weight: 650; cursor: pointer; }
.kx-bell-badge { position: absolute; top: -4px; right: -4px; min-width: 17px; height: 17px; padding: 0 4px; display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--site-surface); border-radius: 50px; background: var(--site-action-bg); color: var(--site-action-text); font-size: 8px; font-weight: 750; }
.kx-bell-badge.is-error { background: var(--site-danger); color: var(--site-bg); }
.kx-bell-badge[hidden] { display: none; }

/* The sidebar has older !important sizing rules for its account popovers. */
html[data-theme] body.has-kx-sidebar aside.kx-sidebar #sidebar-bell-btn.kx-sidebar-notifications {
  width: 44px !important;
  height: 44px !important;
  min-width: 44px;
  min-height: 44px;
  padding: 0 !important;
}
html[data-theme] body.has-kx-sidebar aside.kx-sidebar #sidebar-bell-popover.kx-bell-panel:not(.hidden) {
  width: min(350px, calc(100vw - 32px)) !important;
  max-height: min(500px, calc(100dvh - var(--kx-navbar-offset, 96px) - 110px));
  overflow: hidden !important;
  border-radius: 20px !important;
}

@keyframes kx-notice-enter { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes kx-notice-leave { to { opacity: 0; transform: translateX(14px) scale(.97); } }
@keyframes kx-notice-lifetime { to { transform: scaleX(0); } }
@keyframes kx-bell-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes kx-bell-spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
  #kxcl-toast-container.kx-notice-stack { right: max(12px, env(safe-area-inset-right)); width: calc(100vw - 24px); gap: 8px; }
  .kx-notice { grid-template-columns: 34px minmax(0,1fr) 44px; gap: 10px; padding: 14px 6px 16px 14px; border-radius: 16px; }
  .kx-notice-icon { width: 34px; height: 34px; border-radius: 10px; }
  .kx-notice-title { font-size: 12px; }
  .kx-notice-message { font-size: 11px; }
  .kx-notice-close, .kx-bell-close { width: 44px; height: 44px; }
  .kx-notice-close { margin-top: -6px; }
  html[data-theme] #sidebar-bell-popover.kx-bell-panel { width: min(310px, calc(100vw - 36px)); max-height: calc(100dvh - 220px); }
  html[data-theme] body.has-kx-sidebar aside.kx-sidebar #sidebar-bell-popover.kx-bell-panel:not(.hidden) { width: min(310px, calc(100vw - 36px)) !important; }
  .kx-bell-heading { padding: 14px 10px 14px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .kx-notice, .kx-notice.is-leaving, html[data-theme] #sidebar-bell-popover.kx-bell-panel { animation: none; }
  .kx-bell-state-icon.is-loading svg { animation: none; }
  .kx-notice-progress { display: none; }
  .kx-notice-close, .kx-bell-close, .kx-bell-notice, .kx-bell-footer a { transition: none; }
}
