:root {
  --bg-app: #f5f9ff;
  --panel: #ffffff;
  --panel-alt: #f8fbff;
  --text: #0f172a;
  --muted: #64748b;
  --line: rgba(148, 163, 184, 0.4);
  --accent: #3b82f6;
  --accent-muted: rgba(59, 130, 246, 0.1);
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.1);
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --app-shell-gradient: linear-gradient(135deg, rgba(245, 249, 255, 0.92) 0%, rgba(219, 234, 254, 0.78) 40%, rgba(255, 255, 255, 0.92) 100%);
  --surface-border: rgba(148, 163, 184, 0.18);
  --space-0: 0px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-9: 36px;
  --space-10: 40px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg-app);
  line-height: 1.4;
}

button {
  font-family: inherit;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--app-shell-gradient);
  background-size: cover;
  color: var(--text);
}

.app-shell--fixed {
  background-attachment: fixed;
}

.app-shell--centered {
  align-items: center;
  justify-content: center;
}

.surface-card {
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: var(--space-6);
  color: inherit;
}

.surface-card--glass {
  background: rgba(255, 255, 255, 0.92);
}

.surface-card--muted {
  background: var(--panel-alt);
}

.surface-card--bordered {
  border: 1px solid var(--surface-border);
}

.surface-card--inset {
  box-shadow: none;
  border: 1px solid var(--surface-border);
}

.surface-card--compact {
  padding: var(--space-4);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.stack--gap-sm {
  gap: var(--space-3);
}

.stack--gap-lg {
  gap: var(--space-6);
}

.loading {
  margin: auto;
  padding: 32px 40px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  font-weight: 600;
  text-align: center;
}

/* Unified button styles (shared across apps) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 10px 18px rgba(59, 130, 246, 0.25);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
}

.btn:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.75);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.18);
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn--icon {
  padding: 0;
  width: 36px;
  height: 36px;
  border-radius: 12px;
}

.btn--icon:hover,
.btn--icon:focus-visible {
  transform: none;
  box-shadow: none;
}

.focus-ring {
  outline: none;
}

.focus-ring:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.75);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.18);
}

/* Shared notifications overlay */
.notifications-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  padding: var(--space-8);
  background: rgba(15, 23, 42, 0.05);
}

.notifications-panel {
  width: min(480px, calc(100vw - 48px));
  max-height: calc(100vh - 160px);
  margin-top: 72px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  backdrop-filter: blur(8px);
}

.notifications-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.notifications-header__titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.notifications-header strong {
  font-size: 18px;
}

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

.notifications-actions {
  display: inline-flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Rich notifications modal */
.notifrich-modal { width: min(1200px, calc(100vw - 96px)); max-height: calc(100vh - 96px); margin: auto; background: rgba(255,255,255,.98); border-radius: 20px; box-shadow: 0 28px 64px rgba(15,23,42,.22); padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); backdrop-filter: blur(8px); overflow: auto; }
.notifrich-header { display:flex; align-items:center; justify-content:space-between; gap: var(--space-3); }
.notifrich-header .tabs { display:flex; align-items:center; gap: var(--space-2); flex-wrap: wrap; }
.notifrich-tab { all: unset; display:inline-flex; align-items:flex-start; gap:8px; padding:8px 12px; border-radius: 6px; border:1px solid var(--surface-border); cursor:pointer; background: rgba(241,245,249,.72); color: inherit; }
.notifrich-tab.is-active { background: var(--accent-muted); border-color: rgba(59,130,246,.45); box-shadow: 0 8px 20px rgba(59,130,246,.18); }
.notifrich-tab .close { margin-left: 4px; opacity: 0; transition: opacity .15s ease; }
.notifrich-tab:hover .close { opacity: 1; }

.notifrich-tab .label { display: inline-block; line-height: 1.1; }
.notifrich-tab .meta-line { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

.notifrich-body { display:grid; grid-template-columns: minmax(0, 2.3fr) minmax(0, 0.9fr); gap: var(--space-4); align-items: start; }
@media (max-width: 1080px){ .notifrich-body { grid-template-columns: minmax(0,1fr); } }
.notifrich-body.is-empty { grid-template-columns: 1fr; }

.notifrich-list ul { margin: 0; padding: 0; list-style: none; display:flex; flex-direction: column; gap: var(--space-2); }
.notifrich-item { display:flex; align-items:center; justify-content: space-between; gap: var(--space-3); border:1px solid var(--surface-border); border-radius: 14px; background: #fff; padding: 10px 12px; cursor: pointer; }
.notifrich-item.is-seen { opacity: .85; }
.notifrich-item .title { font-weight: 600; min-width: 0; font-size: 14px; line-height: 1.25; }
.notifrich-item .meta { color: var(--muted); font-size: 12px; }
.notifrich-item .actions { display: inline-flex; gap: var(--space-2); }
.notifrich-item .actions .btn { padding: 4px 6px; min-width: 0; }

.notifrich-preview { border:1px solid var(--surface-border); border-radius: 14px; background: #fff; padding: 0; overflow: hidden; height: 560px; max-height: calc(100vh - 240px); }
.notifrich-iframe { display:block; width:100%; height: 100%; border:0; }

/* Empty state */
.notifrich-empty-state { display:flex; flex-direction:column; align-items:center; justify-content:center; gap: var(--space-3); border:1px dashed var(--surface-border); border-radius: 14px; background: rgba(248,250,252,.7); padding: 40px; min-height: 360px; text-align: center; }
.notifrich-empty-state .icon { font-size: 42px; line-height: 1; opacity: .85; }
.notifrich-empty-state .title { font-weight: 600; font-size: 16px; }
.notifrich-empty-state .hint { color: var(--muted); font-size: 13px; }

/* Admin tabs layout */
.admin-tabs { display:flex; align-items:center; gap: var(--space-2); flex-wrap: wrap; }

.btn.danger, .btn.ghost.danger { color: var(--danger); }
.btn.danger:hover, .btn.ghost.danger:hover { box-shadow: 0 12px 28px rgba(239,68,68,.22); }

.notifications-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.notifications-section h4 {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.notifications-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.notifications-list--important .notification-card {
  border-left: 4px solid var(--accent);
  background: rgba(59, 130, 246, 0.08);
}

.notifications-loading,
.notifications-empty {
  font-size: 14px;
  text-align: center;
  color: var(--muted);
}

.notification-card {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 16px;
  padding: var(--space-4);
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

.notification-card.is-seen {
  opacity: 0.82;
}

.notification-card.notification-error {
  border-color: rgba(239, 68, 68, 0.4);
}

.notification-card.notification-success {
  border-color: rgba(34, 197, 94, 0.4);
}

.notification-card__titles {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.notification-card__labels {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.notification-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.18);
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 600;
}

.notification-emitter {
  font-size: 11px;
  color: var(--muted);
}

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

.notification-card__title {
  font-weight: 600;
  font-size: 15px;
}

.notification-card__body {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.notification-card__actions {
  display: flex;
  justify-content: flex-end;
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  margin: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  gap: 18px;
}

.app-topbar__brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  font-weight: 700;
}

.app-topbar__logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #e0f2fe, #ffe5ec);
  display: grid;
  place-items: center;
  font-size: 24px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.app-topbar__brand-labels {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-topbar__title {
  font-size: 18px;
  line-height: 1.1;
}

.app-topbar__brand small {
  font-size: 12px;
  color: var(--muted);
}

.app-topbar__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-topbar__actions-group {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.app-topbar__icon-button {
  border: none;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.16s ease, transform 0.16s ease;
  color: inherit;
  text-decoration: none;
}

.app-topbar__icon-button:hover,
.app-topbar__icon-button:focus-visible {
  background: rgba(59, 130, 246, 0.14);
  transform: translateY(-1px);
}

.app-topbar__badge {
  position: absolute;
  top: -4px;
  right: -2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  box-shadow: 0 6px 12px rgba(239, 68, 68, 0.35);
}

.app-user-menu {
  position: relative;
}

.app-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.26);
  background: rgba(255, 255, 255, 0.9);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.app-user-chip:hover,
.app-user-chip:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
  border-color: rgba(59, 130, 246, 0.45);
}

.app-user-chip__avatar {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
  font-weight: 700;
  font-size: 15px;
}

.app-user-chip__labels {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
}

.app-user-chip__name {
  font-size: 14px;
}

.app-user-chip__role {
  font-size: 11px;
  color: var(--muted);
}

/* Badge helpers */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.badge--success {
  background: rgba(34, 197, 94, 0.18);
  color: #166534;
}

.badge--warning {
  background: rgba(245, 158, 11, 0.2);
  color: #92400e;
}

.badge--danger {
  background: rgba(248, 113, 113, 0.22);
  color: #b91c1c;
}

.badge--info {
  background: rgba(59, 130, 246, 0.18);
  color: #1d4ed8;
}

.badge--muted {
  background: rgba(148, 163, 184, 0.24);
  color: #475569;
}

.app-user-menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 30px rgba(15, 23, 42, 0.18);
  border: 1px solid rgba(148, 163, 184, 0.18);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 90;
}

.app-user-menu__panel[hidden] {
  display: none !important;
}

.app-user-menu__identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-user-menu__avatar {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
  font-weight: 700;
  font-size: 18px;
}

.app-user-menu__name {
  font-weight: 700;
  font-size: 15px;
}

.app-user-menu__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  color: var(--muted);
}

.app-user-menu__panel hr {
  margin: 6px -4px;
  border: none;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.app-user-menu__item {
  appearance: none;
  border: none;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.16s ease, color 0.16s ease;
}

.app-user-menu__item:hover,
.app-user-menu__item:focus-visible {
  background: rgba(148, 163, 184, 0.16);
}

.app-user-menu__item--danger {
  color: #dc2626;
}

.app-user-menu__item-icon {
  width: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pack-slot-error {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
  border: 1px dashed var(--surface-border);
  border-radius: var(--radius-lg);
  background: rgba(248, 250, 252, 0.85);
  color: var(--muted);
  font-size: 14px;
}

.pack-slot-error strong {
  font-size: 15px;
  color: var(--text);
}

/* Board configuration modal */
.board-config__overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  z-index: 120;
  backdrop-filter: blur(2px);
}

.board-config {
  background: rgba(255, 255, 255, 0.98);
  border-radius: 24px;
  width: min(960px, 95vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 32px 60px rgba(15, 23, 42, 0.25);
  overflow: hidden;
}

.board-config__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 28px 16px;
  gap: 16px;
}

.board-config__header h3 {
  margin: 0;
  font-size: 20px;
}

.board-config__subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: rgba(100, 116, 139, 0.9);
}

.board-config__body {
  display: flex;
  flex: 1;
  min-height: 420px;
}

.board-config__tabs {
  width: 210px;
  padding: 0 0 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-right: 1px solid rgba(148, 163, 184, 0.18);
}

.board-config__tab {
  appearance: none;
  border: none;
  background: none;
  text-align: left;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: background .18s ease, color .18s ease;
}

.board-config__tab:hover,
.board-config__tab:focus-visible {
  background: rgba(148, 163, 184, 0.18);
  color: #1f2937;
}

.board-config__tab.is-active {
  background: rgba(59, 130, 246, 0.18);
  color: #1d4ed8;
}

.board-config__content {
  flex: 1;
  padding: 0 32px 32px;
  overflow-y: auto;
  position: relative;
}

.board-config__panel {
  display: block;
  animation: board-config-fade-in .18s ease;
}

.board-config__panel[hidden] {
  display: none !important;
}

.board-config__logic {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 560px;
}

.board-config__placeholder {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: rgba(241, 245, 249, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.16);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.board-config__placeholder strong {
  color: var(--text);
  font-size: 15px;
}

.board-config__form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 520px;
  padding-bottom: 12px;
}

.board-config__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.board-config__field input {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  font-size: 16px;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.board-config__field input:focus-visible,
.board-config__field input:focus {
  border-color: rgba(59, 130, 246, 0.6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.board-config__meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  font-size: 13px;
  margin: 0;
}

.board-config__meta div {
  padding: 12px;
  border-radius: 12px;
  background: rgba(248, 250, 255, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.board-config__meta dt {
  margin: 0 0 4px;
  font-weight: 600;
  color: #1f2937;
}

.board-config__meta dd {
  margin: 0;
  color: #475569;
}

.board-config__error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(248, 113, 113, 0.18);
  color: #b91c1c;
  font-size: 13px;
}

.board-config__footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.board-config__panels {
  position: relative;
}

.board-config__panels[hidden] {
  display: none !important;
}

.board-config__slot-root > [data-slot-contribution] {
  margin-top: 0;
}

@keyframes board-config-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 900px) {
  .board-config__overlay {
    padding: 16px;
  }
  .board-config {
    width: 100%;
    max-height: 94vh;
  }
  .board-config__body {
    flex-direction: column;
  }
  .board-config__tabs {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    padding: 0 24px 12px;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .board-config__tab {
    flex: 1;
    text-align: center;
  }
  .board-config__content {
    padding: 24px;
  }
}

@media (max-width: 768px) {
  .notifications-panel {
    width: min(100%, calc(100vw - 32px));
    margin-top: 48px;
  }

  .app-topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .app-topbar__actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}
