@font-face {
  font-family: "Inter";
  src: url("../fonts/inter/inter-latin-variable.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: optional;
}

:root {
  --ink: #242a30;
  --ink-soft: #6f7b84;
  --surface: #ffffff;
  --paper: #ffffff;
  --sidebar: #2d353c;
  --sidebar-deep: #242a30;
  --sidebar-text: #c7d0d7;
  --sidebar-muted: #82909a;
  --primary: #245f91;
  --primary-deep: #194b75;
  --primary-soft: #e9f0f6;
  --primary-light: #4d81aa;
  --action-bg: #2f6f9f;
  --action-hover: #245f91;
  --action-pressed: #194b75;
  --action-outline-border: #7fa3be;
  --action-outline-text: #245f91;
  --action-outline-hover: #f3f7fa;
  --action-outline-active: #e9f0f6;
  --line: #cfd6dd;
  --danger: #b54343;
  --warning: #926d16;
  --led-active: #2dbb78;
  --led-invited: #429bdc;
  --led-suspended: #e0a126;
  --led-archived: #91a4b1;
  --led-deny: #e95c68;
  --led-allow: #2dbb78;
  --led-own: #e0a126;
  --shadow: 0 8px 24px rgba(36, 42, 48, .1);
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--surface); }
body {
  min-height: 100dvh; margin: 0; background: var(--surface); color: var(--ink);
  font-family: var(--font-sans); font-size: .875rem; line-height: 1.58; letter-spacing: .006em;
}
button, input, select, textarea { font: inherit; }
a { color: var(--primary-deep); text-underline-offset: 3px; }
a:hover { color: var(--primary); }
:focus-visible { outline: 3px solid var(--primary-light); outline-offset: 3px; }

.skip-link {
  position: fixed; z-index: 1200; left: 1rem; top: -5rem; padding: .65rem 1rem;
  border-radius: 0 0 .45rem .45rem; background: var(--primary); color: #fff;
  font-weight: 800; text-decoration: none; transition: top .16s ease;
}
.skip-link:focus { top: 0; color: #fff; }

.brand {
  display: inline-flex; align-items: center; color: var(--ink); text-decoration: none;
}
.brand:hover { color: var(--ink); }
.brand-logo {
  display: block; width: 12rem; height: auto; max-width: 100%;
  image-rendering: auto; shape-rendering: geometricPrecision;
}
.brand-logo-white { display: none; }
html[data-theme="dark"] .auth-header .brand-logo-color { display: none; }
html[data-theme="dark"] .auth-header .brand-logo-white { display: block; }
.portal-tile {
  display: inline-grid; place-items: center; width: 2rem; height: 2rem; flex: 0 0 2rem;
  border: 1px solid color-mix(in srgb, var(--portal-color) 72%, #000);
  border-radius: .48rem; background: var(--portal-color); color: #fff;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.18), 0 2px 7px rgba(0,0,0,.12);
  font-size: .68rem; font-weight: 900; letter-spacing: -.025em; line-height: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,.55);
}
.portal-tile-md { width: 2.5rem; height: 2.5rem; flex-basis: 2.5rem; border-radius: .55rem; font-size: .85rem; }
.portal-tile-lg { width: 3rem; height: 3rem; flex-basis: 3rem; border-radius: .7rem; font-size: 1rem; }
.portal-tile-nav { width: 1.55rem; height: 1.55rem; flex-basis: 1.55rem; margin-right: .72rem; border-radius: .38rem; font-size: .56rem; }
.portal-tile-header { width: 1.65rem; height: 1.65rem; flex-basis: 1.65rem; border-radius: .4rem; font-size: .58rem; }
.portal-tile-menu { width: 1.7rem; height: 1.7rem; flex-basis: 1.7rem; border-radius: .4rem; font-size: .58rem; }
.status-label { display: inline-flex; align-items: center; gap: .45rem; white-space: nowrap; }
.status-indicator {
  display: block !important; flex: 0 0 13px !important; flex-shrink: 0 !important;
  width: 13px !important; height: 13px !important; min-width: 13px !important; min-height: 13px !important;
  max-width: 13px !important; max-height: 13px !important; aspect-ratio: 1 / 1;
  align-self: center; padding: 0; border: 0; border-radius: 50% !important;
}
.status-active { background: var(--led-active); }
.status-invited { background: var(--led-invited); }
.status-suspended { background: var(--led-suspended); }
.status-archived { background: var(--led-archived); }
.profile-avatar {
  display: inline-grid; place-items: center; flex: 0 0 auto; overflow: hidden;
  border-radius: 50%; background: var(--avatar-color, var(--primary)); color: var(--avatar-ink, #fff);
  font-weight: 900; letter-spacing: .02em; text-transform: uppercase;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22), 0 2px 6px rgba(24,42,50,.2);
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-avatar-header { width: 2rem; height: 2rem; font-size: .67rem; }
.profile-avatar-md { width: 2.25rem; height: 2.25rem; min-width: 2.25rem; min-height: 2.25rem; max-width: 2.25rem; max-height: 2.25rem; flex-basis: 2.25rem; font-size: .68rem; }
.profile-avatar-lg { width: 6.5rem; height: 6.5rem; font-size: 1.65rem; }
.profile-avatar-list { width: 2.35rem; height: 2.35rem; flex-basis: 2.35rem; font-size: .68rem; }
.account-list-link { display: inline-flex; align-items: center; gap: .65rem; color: inherit; text-decoration: none; }
.account-list-link:hover { color: var(--primary-deep); }
.profile-editor { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 1.5rem; align-items: start; }
.profile-appearance { min-width: 0; }
.appearance-option { display: inline-flex; align-items: center; gap: .45rem; font-size: .84rem; font-weight: 700; }
.avatar-colors { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: 1rem; }
.avatar-color-choice { position: relative; cursor: pointer; }
.avatar-color-choice input { position: absolute; opacity: 0; pointer-events: none; }
.avatar-color-choice > span:first-of-type {
  display: block; width: 2rem; height: 2rem; border: .2rem solid var(--paper);
  border-radius: 50%; background: var(--choice-color); box-shadow: 0 0 0 1px var(--line);
}
.avatar-color-choice input:checked + span { box-shadow: 0 0 0 3px var(--primary); }
.profile-file-control {
  display: flex; align-items: center; gap: .75rem; min-height: 2.62rem;
  padding: .35rem; border: 1px solid #bdc7d0; border-radius: .4rem; background: var(--paper);
}
.profile-file-control .btn { flex: 0 0 auto; min-height: 2.1rem; padding: .35rem .7rem; }
.profile-file-name { min-width: 0; overflow: hidden; color: var(--ink-soft); font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }

/* Anonymous and Identity screens */
.auth-shell { min-height: 100dvh; display: flex; flex-direction: column; }
.auth-header {
  height: 4.4rem; display: flex; align-items: center; justify-content: space-between;
  padding: 0 clamp(1.25rem, 5vw, 4rem); background: var(--paper); border-bottom: 1px solid var(--line);
}
.auth-context { color: var(--ink-soft); font-size: .76rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.auth-main { flex: 1; display: grid; place-items: start center; padding: clamp(2.2rem, 8vh, 5.75rem) 1rem 2rem; }
.auth-card {
  width: min(100%, 28.75rem); padding: clamp(1.5rem, 5vw, 2.45rem); background: var(--paper);
  border: 1px solid var(--line); border-radius: .75rem; box-shadow: var(--shadow);
}
.auth-card > :first-child { margin-top: 0; }
.auth-card h1 { font-size: clamp(1.45rem, 4vw, 1.9rem); margin: .45rem 0 .55rem; letter-spacing: -.022em; }
.auth-card .text-muted, .auth-card p { color: var(--ink-soft) !important; }
.auth-footer { padding: 1.35rem 1rem; color: var(--ink-soft); font-size: .75rem; text-align: center; }

/* Application frame */
.app-shell { min-height: 100dvh; }
.app-sidebar {
  position: fixed; z-index: 1050; top: 0; bottom: 0; left: 0; width: 15.6rem;
  display: flex; flex-direction: column; overflow-y: auto; background: var(--sidebar);
  border-right: 1px solid rgba(255,255,255,.05); color: var(--sidebar-text);
  transition: transform .2s ease, width 0.2s ease;
}
.sidebar-brand {
  min-height: 4.35rem; display: flex; align-items: center; padding: 0 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .brand { color: #f3f7f7; }
.sidebar-brand-logo { display: block; width: 10rem; overflow: hidden; transition: width .2s ease; }
.sidebar-brand-logo .brand-logo { width: 10rem; max-width: none; height: auto; }
.sidebar-nav { padding: 1.05rem .72rem; }
.nav-label {
  display: block; padding: .55rem .72rem .4rem; color: var(--sidebar-muted);
  font-family: var(--font-mono); font-size: .62rem; letter-spacing: .11em; text-transform: uppercase;
  transition: opacity 0.2s ease;
}
.side-link {
  position: relative; display: flex; align-items: center; min-height: 2.65rem; margin: .12rem 0;
  padding: .55rem .75rem .55rem 1rem; border-radius: .36rem; color: var(--sidebar-text);
  font-size: .83rem; font-weight: 400; letter-spacing: .012em; text-decoration: none;
  transition: background-color 0.16s ease, color 0.16s ease;
}
.side-link:hover { background: #3e4750; color: #fff; }
.side-link.active { background: #20272d; color: #fff; font-weight: 500; }
.side-link-portal { padding-left: 1.35rem; font-size: .79rem; }
.side-link.has-active-child { color: #fff; }
.side-menu-heading { display: flex; align-items: center; min-width: 0; }
.side-menu-heading > .side-link { min-width: 0; flex: 1; }
.side-menu-flyout-trigger { display: none; border: 0; background: transparent; cursor: pointer; }
.side-menu-flyout-trigger:hover, .side-menu-flyout-trigger:focus-visible { background: #3e4750; color: #fff; }
.side-menu-flyout {
  position: fixed; z-index: 1060; width: min(15rem, calc(100vw - 5.5rem));
  max-height: calc(100dvh - 1rem); overflow-y: auto; padding: .45rem;
  border: 1px solid rgba(255,255,255,.14); border-radius: .45rem;
  background: var(--sidebar); box-shadow: 0 9px 24px rgba(0,0,0,.28);
}
.side-menu-flyout[hidden] { display: none; }
.side-menu-flyout-link {
  display: block; padding: .52rem .6rem; border-radius: .32rem;
  color: var(--sidebar-text); font-size: .83rem; font-weight: 400; text-decoration: none;
}
.side-menu-flyout-link:hover, .side-menu-flyout-link:focus-visible { background: #3e4750; color: #fff; }
.side-menu-flyout-link.active { background: #20272d; color: #fff; font-weight: 500; }
.side-menu-flyout-link--primary { font-weight: 700; }
.side-menu-flyout-link--primary.active { font-weight: 700; }
.side-menu-flyout-link--sub,
.side-menu-flyout-link--sub.active { font-weight: 400; }
html[data-theme="dark"] .side-menu-flyout .side-menu-flyout-link { color: var(--sidebar-text); }
html[data-theme="dark"] .side-menu-flyout .side-menu-flyout-link:is(:hover, :focus-visible, .active) { color: #fff; }
.side-submenu-toggle {
  display: grid; place-items: center; flex: 0 0 2rem; width: 2rem; height: 2rem;
  border: 0; border-radius: .32rem; background: transparent; color: var(--sidebar-text);
}
.side-submenu-toggle::after {
  content: ""; width: .46rem; height: .46rem; border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translate(-1px, -1px);
  transition: transform .16s ease;
}
.side-submenu-toggle[aria-expanded="true"]::after { transform: rotate(225deg) translate(-1px, -1px); }
.side-submenu-toggle:hover, .side-submenu-toggle:focus-visible { background: #3e4750; color: #fff; }
.side-submenu {
  list-style: none; margin: .1rem 0 .45rem 1.45rem; padding: 0 0 0 .65rem;
  border-left: 1px solid rgba(255,255,255,.18);
}
.side-submenu[hidden] { display: none; }
.side-submenu-link {
  display: block; padding: .45rem .6rem; border-radius: .32rem;
  color: var(--sidebar-text); font-size: .78rem; line-height: 1.35; text-decoration: none;
}
.side-submenu-link:hover, .side-submenu-link:focus-visible { background: #3e4750; color: #fff; }
.side-submenu-link.active { background: #20272d; color: #fff; font-weight: 500; }
.nav-icon {
  width: 1rem; height: 1rem; min-width: 1rem; margin-right: .72rem; flex-shrink: 0;
  color: #84929b; transition: color .16s ease;
}
.side-link:hover .nav-icon { color: #fff; }
.side-link.active .nav-icon { color: #fff; }
.sidebar-tooltip {
  --bs-tooltip-bg: #111820;
  --bs-tooltip-color: #fff;
  --bs-tooltip-opacity: .98;
  --bs-tooltip-max-width: 15rem;
  z-index: 1100;
}
.sidebar-tooltip .tooltip-inner {
  padding: .48rem .7rem; border: 1px solid rgba(255,255,255,.12);
  border-radius: .38rem; box-shadow: 0 5px 16px rgba(0,0,0,.28);
  font-size: .76rem; font-weight: 750; letter-spacing: .01em;
}
html[data-theme="dark"] .sidebar-tooltip {
  --bs-tooltip-bg: #f2f5f7;
  --bs-tooltip-color: #18232c;
}
html[data-theme="dark"] .sidebar-tooltip .tooltip-inner {
  border-color: rgba(24,35,44,.18);
  box-shadow: 0 5px 18px rgba(0,0,0,.42);
}
.sidebar-bottom { margin-top: auto; padding: .8rem .72rem 1rem; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-bottom .side-link { color: #c5d0d5; }

.desktop-toggle {
    display: none; background: transparent; border: none; color: var(--sidebar-muted);
    cursor: pointer; padding: 0.4rem; border-radius: 0.3rem; margin-left: auto;
}
.desktop-toggle:hover { color: #fff; background: rgba(255,255,255,0.1); }
.icon-expand { display: none; }
.sidebar-expand { display: none; }
@media (min-width: 768px) {
    .desktop-toggle { display: block; }
    body.sidebar-collapsed .app-sidebar { width: 4.5rem; }
    body.sidebar-collapsed .app-main { margin-left: 4.5rem; }
    body.sidebar-collapsed .sidebar-brand-logo { width: 2.35rem; }
    body.sidebar-collapsed .nav-label { opacity: 0; pointer-events: none; height: 0; padding: 0; margin: 0; overflow: hidden; }
    body.sidebar-collapsed .sidebar-nav { padding-left: .5rem; padding-right: .5rem; }
    body.sidebar-collapsed .side-link { width: 2.75rem; padding: 0; margin-left: auto; margin-right: auto; justify-content: center; }
    body.sidebar-collapsed .side-link .nav-icon { margin-right: 0 !important; }
    body.sidebar-collapsed .side-link span:not(.portal-tile) { display: none; }
    body.sidebar-collapsed .side-link .portal-tile { margin-right: 0; }
    body.sidebar-collapsed .side-menu-heading { justify-content: center; }
    body.sidebar-collapsed .side-menu-heading > .side-link { flex: 0 0 2.75rem; }
    body.sidebar-collapsed .side-menu-group-has-flyout .side-menu-heading > a.side-link { display: none; }
    body.sidebar-collapsed .side-menu-flyout-trigger { display: flex; }
    body.sidebar-collapsed .side-submenu-toggle { display: none; }
    body.sidebar-collapsed .side-submenu { display: none; }
    body.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0; }
    body.sidebar-collapsed .sidebar-bottom { padding: .8rem .5rem 1rem; }
    body.sidebar-collapsed .desktop-toggle { display: none; }
    body.sidebar-collapsed .sidebar-expand { display: grid; }
}

.app-main { min-width: 0; margin-left: 15.6rem; transition: margin-left 0.2s ease; }
.topbar {
  position: sticky; z-index: 1020; top: 0; height: 4.35rem; display: flex; align-items: center;
  justify-content: space-between; gap: 1rem; padding: 0 2rem; background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(10px);
}
.topbar-leading, .header-actions { min-width: 0; height: 100%; display: flex; align-items: center; gap: .8rem; }
.topbar-context { color: var(--ink-soft); font-size: .76rem; font-weight: 800; letter-spacing: .085em; text-transform: uppercase; }
.portal-switcher-button {
  display: inline-flex; align-items: center; gap: .55rem; min-height: 2.45rem; max-width: min(22rem, 34vw);
  padding: .35rem .7rem; border: 1px solid var(--line); border-radius: .48rem;
  background: var(--paper); color: var(--ink); font-size: .8rem; font-weight: 800;
}
.portal-switcher-button > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-switcher-button:hover, .portal-switcher-button[aria-expanded="true"] {
  border-color: var(--primary-light); background: var(--primary-soft); color: var(--ink);
}
.portal-switcher .dropdown-menu {
  width: min(22rem, calc(100vw - 2rem)); max-height: min(34rem, calc(100dvh - 5.5rem));
  overflow-y: auto; overscroll-behavior: contain;
}
.portal-switcher-search {
  position: sticky; z-index: 2; top: 0; padding: .65rem; border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.portal-switcher-search .form-control { min-height: 2.35rem; }
.portal-switcher-empty { padding: .8rem 1rem; font-size: .8rem; }
.portal-switcher-item { display: flex; align-items: center; gap: .65rem; }
.menu-toggle {
  display: none; width: 2.55rem; height: 2.55rem; padding: 0; border: 1px solid var(--line); border-radius: .42rem;
  background: var(--paper); color: var(--ink);
}
.menu-toggle svg { width: 1.15rem; height: 1.15rem; }
.sidebar-expand, .theme-toggle, .push-indicator {
  width: 2.35rem; height: 2.35rem; padding: 0; align-items: center; justify-content: center; border: 1px solid var(--line);
  border-radius: .42rem; background: var(--paper); color: var(--ink-soft);
}
.theme-toggle, .push-indicator { display: inline-grid; flex: 0 0 auto; }
.sidebar-expand:hover, .theme-toggle:hover, .push-indicator:hover { border-color: var(--primary-light); color: var(--primary-deep); background: var(--primary-soft); }
.sidebar-expand svg, .theme-icon, .push-icon-bell { width: 1.05rem; height: 1.05rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-icon-dark { display: none; }
html[data-theme="dark"] .theme-icon-light { display: none; }
html[data-theme="dark"] .theme-icon-dark { display: block; }
.account-menu { height: 100%; display: flex; flex: 0 0 auto; align-items: center; gap: .5rem; }
.account-identity { display: inline-flex; align-items: center; gap: .28rem; min-width: 0; }
.account-name { display: inline-flex; align-items: center; min-height: 2.35rem; max-width: 15rem; padding: 0 .15rem; overflow: hidden; color: var(--ink-soft); font-size: .78rem; font-weight: 700; line-height: 1; text-overflow: ellipsis; white-space: nowrap; }
.account-action { display: inline-flex; align-items: center; justify-content: center; min-height: 2.35rem; padding: 0 .72rem !important; border: 1px solid var(--line) !important; border-radius: .42rem; background: var(--paper) !important; line-height: 1; }
.account-link { color: var(--ink); font-size: .78rem; font-weight: 800; text-decoration: none; }
.account-link:hover { color: var(--primary-deep); text-decoration: underline; }
.logout-button {
  color: var(--ink-soft); font-size: .78rem; font-weight: 700; text-decoration: none;
}
.logout-button:hover { border-color: var(--danger) !important; color: var(--danger); }
.logout-form { margin: 0; }
.content-area { min-height: calc(100dvh - 4.35rem); padding: clamp(1.25rem, 3vw, 2.25rem); }
.site-footer { margin-top: auto; padding: 1.25rem 0 .2rem; color: var(--ink-soft); font-size: .72rem; }
.site-footer::before { content: ""; display: block; margin-bottom: 1.2rem; border-top: 1px solid var(--line); }
.sidebar-backdrop { display: none; }

/* Bootstrap refinement for pages supplied by other modules */
h1, .h1 { margin: 0 0 1.4rem; color: var(--ink); font-size: clamp(1.45rem, 3.2vw, 2rem); font-weight: 800; letter-spacing: -.022em; }
.content-area h1:has(+ p), .auth-card h1:has(+ p) { margin-bottom: 0; }
h2, .h2 { color: var(--ink); font-size: 1.22rem; font-weight: 800; letter-spacing: -.015em; }
h3, .h3 { color: var(--ink); font-size: 1rem; font-weight: 800; letter-spacing: -.008em; }
p { color: var(--ink-soft); }
.eyebrow { display: block; margin-bottom: .4rem; color: var(--primary); font-family: var(--font-mono); font-size: .67rem; font-weight: 500; letter-spacing: .09em; text-transform: uppercase; }
.lead { max-width: 52rem; color: var(--ink-soft); font-size: .95rem; }
.card {
  border: 1px solid var(--line); border-radius: .6rem; background: var(--paper);
  box-shadow: 0 2px 7px rgba(30, 50, 59, .025);
}
.card-header { padding: 1rem 1.2rem; border-bottom-color: var(--line); background: transparent; color: var(--ink); font-weight: 800; }
.card-body { padding: 1.2rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: 2.62rem; padding: .5rem .85rem; vertical-align: middle;
  border-radius: .4rem; font-size: .81rem; font-weight: 800;
  line-height: 1.25; letter-spacing: .02em; text-align: center;
}
.btn.btn-sm { min-height: 2.15rem; padding: .35rem .7rem; font-size: .76rem; line-height: 1.2; }
.btn.btn-lg { min-height: 3rem; padding: .7rem 1.15rem; font-size: .95rem; }
.btn:focus-visible { outline: 2px solid #8fc5ee; outline-offset: 2px; }
.btn.is-loading,
.account-action.is-loading {
  display: inline-flex; align-items: center; justify-content: center;
  cursor: wait;
}
.btn-loading-indicator {
  width: 1em; height: 1em; flex: 0 0 1em; border: .14em solid currentColor;
  border-right-color: transparent; border-radius: 50%; animation: button-loading-spin .7s linear infinite;
}
@keyframes button-loading-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn-loading-indicator { animation-duration: 1.4s; }
}
.btn-primary { background: var(--action-bg); border-color: var(--action-bg); color: #fff; }
.btn-primary:is(:hover, :focus-visible) {
  background: var(--action-hover); border-color: var(--action-hover); color: #fff;
}
.btn-primary:is(:active, .active, [aria-pressed="true"]) {
  background: var(--action-pressed); border-color: var(--action-pressed); color: #fff;
}
:is(.btn-secondary, .btn-outline-primary, .btn-outline-secondary) {
  background: transparent; border-color: var(--action-outline-border); color: var(--action-outline-text);
}
:is(.btn-secondary, .btn-outline-primary, .btn-outline-secondary):is(:hover, :focus-visible) {
  background: var(--action-outline-hover); border-color: var(--action-outline-border); color: var(--action-outline-text);
}
:is(.btn-secondary, .btn-outline-primary, .btn-outline-secondary):is(:active, .active, [aria-pressed="true"]) {
  background: var(--action-outline-active); border-color: var(--action-outline-border); color: var(--action-outline-text);
}
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover, .btn-danger:focus-visible { background: #933838; border-color: #933838; color: #fff; }
.btn-danger:active, .btn-danger.active, .btn-danger[aria-pressed="true"] { background: #ab4848; border-color: #ab4848; color: #fff; }
.btn-outline-danger { border-color: var(--danger); color: var(--danger); }
.btn-outline-danger:hover, .btn-outline-danger:focus-visible { border-color: #933838; background: #933838; color: #fff; }
.btn-outline-danger:active, .btn-outline-danger.active, .btn-outline-danger[aria-pressed="true"] { border-color: #ab4848; background: #ab4848; color: #fff; }
.btn:disabled, .btn.disabled { border-color: #9aa7b2; background: #9aa7b2; color: #fff; opacity: .72; }
.form-label { margin-bottom: .38rem; color: #344651; font-size: .8rem; font-weight: 800; }
.form-control, .form-select {
  min-height: 2.62rem; border-color: #bdc7d0; border-radius: .4rem; background-color: var(--paper); color: var(--ink); font-size: .86rem;
}
.form-control:focus, .form-select:focus { border-color: var(--primary-light); box-shadow: 0 0 0 .2rem rgba(52, 143, 226, .16); }
.form-check-input:checked { border-color: var(--primary); background-color: var(--primary); }
.form-text { color: var(--ink-soft); font-size: .74rem; }
.text-muted { color: var(--ink-soft) !important; }
.alert { border-width: 1px; border-radius: .5rem; font-size: .84rem; }
.alert-success { border-color: #a8d6cd; background: #edf8f5; color: #195f56; }
.alert-danger { border-color: #e5bcbc; background: #fff5f4; color: #853b3b; }
.alert-warning { border-color: #e5d29b; background: #fffae9; color: #6d5615; }
.table-responsive { border: 1px solid var(--line); border-radius: .55rem; background: var(--paper); }
.table { --bs-table-bg: transparent; --bs-table-color: var(--ink); --bs-table-border-color: var(--line); margin-bottom: 0; font-size: .82rem; }
.table > :not(caption) > * > * { padding: .76rem .9rem; vertical-align: middle; }
.table thead th { border-bottom-width: 1px; color: var(--ink-soft); font-family: var(--font-mono); font-size: .65rem; font-weight: 500; letter-spacing: .065em; text-transform: uppercase; white-space: nowrap; }
.sort-link { display: inline-flex; align-items: center; gap: .35rem; color: inherit; text-decoration: none; }
.sort-link:hover { color: var(--primary-deep); }
.activity-view-switch .nav-link {
  min-height: 2.62rem; display: inline-flex; align-items: center; padding: .5rem .85rem;
  border: 1px solid var(--line); border-radius: .4rem; background: var(--paper);
  color: var(--ink-soft); font-size: .81rem; font-weight: 800;
}
.activity-view-switch .nav-link:hover { border-color: var(--primary-light); background: var(--primary-soft); color: var(--primary-deep); }
.activity-view-switch .nav-link.active { border-color: var(--primary); background: var(--primary); color: #fff; }
.activity-sequence-context { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: .2rem 1.5rem; }
.activity-sequence-context > span:first-child { grid-column: 1 / -1; }
.activity-sequence-context strong { font-size: 1.05rem; }
.table tbody tr:last-child > * { border-bottom: 0; }
.nav-tabs { border-bottom-color: var(--line); }
.nav-tabs .nav-link { border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--ink-soft); font-size: .8rem; font-weight: 800; }
.nav-tabs .nav-link:hover { border-color: transparent; color: var(--primary-deep); }
.nav-tabs .nav-link.active { border-bottom-color: var(--primary); background: transparent; color: var(--primary-deep); }
.portal-identity { min-width: 0; display: inline-flex; align-items: center; gap: .75rem; text-align: left; }
.portal-identity > span:last-child { min-width: 0; }
.portal-identity strong, .portal-identity small { overflow-wrap: anywhere; }
.portal-assignment-list { overflow: hidden; border: 1px solid var(--line); border-radius: .55rem; }
.portal-assignment-card { padding: 1rem 1.2rem; }
.portal-assignment-row {
  min-height: 4.35rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 1rem; border-bottom: 1px solid var(--line);
}
.portal-assignment-row:last-child { border-bottom: 0; }
.portal-permission-card { overflow: hidden; }
.portal-permission-summary {
  display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 1rem;
  padding: 1rem 1.2rem; cursor: pointer; list-style: none;
}
.portal-permission-summary::-webkit-details-marker, .summary-portal > summary::-webkit-details-marker { display: none; }
.portal-permission-summary::after, .summary-portal > summary::after {
  content: "⌄"; color: var(--ink-soft); font-size: 1rem; transition: transform .16s ease;
}
.portal-permission-card[open] > .portal-permission-summary::after, .summary-portal[open] > summary::after { transform: rotate(180deg); }
.portal-summary-meta { margin-right: .4rem; color: var(--ink-soft); font-size: .76rem; font-weight: 700; white-space: nowrap; }
.portal-permission-summary::after { grid-column: 3; }
.portal-permission-body { padding: 1rem 1.2rem 1.2rem; border-top: 1px solid var(--line); }
.permission-list { border: 1px solid var(--line); border-radius: .5rem; }
.permission-row {
  display: grid; grid-template-columns: minmax(0,1fr) minmax(12rem,18rem); align-items: center; gap: 1rem;
  padding: .8rem 1rem; border-bottom: 1px solid var(--line);
}
.permission-row:last-child { border-bottom: 0; }
.portal-remove-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.responsibility-row {
  min-height: 4rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .75rem 0; border-top: 1px solid var(--line);
}
.summary-section { margin-top: 1.5rem; }
.summary-portal { border-top: 1px solid var(--line); }
.summary-portal:last-child { border-bottom: 1px solid var(--line); }
.summary-portal > summary {
  display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 1rem;
  padding: .85rem 0; cursor: pointer; list-style: none;
}
.summary-permissions { padding: .25rem 0 .9rem 2.75rem; }
.summary-permissions > div { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-top: 1px solid var(--line); font-size: .8rem; }
.badge { padding: .35em .55em; border-radius: .28rem; font-size: .67rem; font-weight: 800; letter-spacing: .02em; }
.pagination { --bs-pagination-color: var(--primary-deep); --bs-pagination-border-color: var(--line); --bs-pagination-hover-color: var(--primary-deep); --bs-pagination-hover-bg: var(--primary-soft); --bs-pagination-focus-box-shadow: 0 0 0 .2rem rgba(52, 143, 226, .16); --bs-pagination-active-bg: var(--primary); --bs-pagination-active-border-color: var(--primary); }
.validation-summary-errors, .field-validation-error { color: var(--danger); font-size: .78rem; font-weight: 700; }
.validation-summary-errors {
  padding: .75rem .9rem;
  margin: .9rem 0;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  border-radius: .5rem;
  background: color-mix(in srgb, var(--danger) 8%, var(--paper));
}
.validation-summary-errors ul { list-style: none; margin: 0; padding: 0; }
.validation-summary-errors li + li { margin-top: .35rem; }
.form-validation-hint { display: block; margin: .3rem 0 .65rem; color: var(--danger); font-size: .78rem; font-weight: 700; }
.auth-card .form-control.mb-3 + .form-validation-hint { margin-top: -.7rem; }
.auth-card .form-control.mb-4 + .form-validation-hint { margin-top: -.95rem; }
.notes-form .form-validation-hint { margin: .25rem 0 0; }
.input-validation-error { border-color: var(--danger); }

@media (max-width: 767.98px) {
  .profile-editor { grid-template-columns: 1fr; }
  .app-sidebar { width: min(17.5rem, calc(100vw - 3.25rem)); transform: translateX(-101%); box-shadow: none; }
  body.nav-open { overflow: hidden; }
  body.nav-open .app-sidebar { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; z-index: 1040; inset: 0; background: rgba(12,27,35,.45); }
  body.nav-open .sidebar-backdrop { display: block; }
  .app-main { margin-left: 0; }
  .topbar { height: 4rem; padding: 0 1rem; backdrop-filter: none; }
  .menu-toggle { display: grid; place-items: center; }
  .topbar-context { display: none; }
  .portal-switcher-button { max-width: 45vw; }
  .account-name { display: none; }
  .content-area { min-height: calc(100dvh - 4rem); padding: 1.2rem 1rem; }
  .auth-header { height: 4rem; padding: 0 1rem; }
  .auth-context { display: none; }
  .auth-main { padding-top: 2.25rem; }
  .auth-card { border-radius: .6rem; }
  .table-responsive { margin-left: -1px; margin-right: -1px; border-radius: .45rem; }
  .table > :not(caption) > * > * { padding: .68rem .75rem; }
  .portal-permission-summary { grid-template-columns: minmax(0,1fr) auto; }
  .portal-summary-meta { display: none; }
  .portal-permission-summary::after { grid-column: 2; }
  .permission-row { grid-template-columns: 1fr; gap: .55rem; }
  .portal-assignment-row { align-items: flex-start; }
  .portal-assignment-card { padding: .8rem; }
  .summary-permissions { padding-left: 0; }
  .notes-form-footer { flex-direction: column; align-items: stretch !important; gap: 1rem !important; }
}

/* Push Notifications */
.push-control-wrapper { position: relative; }
.push-indicator { transition: border-color .16s ease, background-color .16s ease, color .16s ease; }
.push-indicator svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.push-indicator.border-success { border-color: #3f9b7c !important; color: #23745e !important; }
.push-indicator.border-danger { border-color: var(--danger) !important; color: var(--danger) !important; }
.push-indicator.border-warning { border-color: var(--warning) !important; color: var(--warning) !important; }
.push-help {
    position: absolute;
    z-index: 1080;
    top: calc(100% + .55rem);
    right: 0;
    width: min(20rem, calc(100vw - 2rem));
    padding: .7rem .8rem;
    border: 1px solid var(--line);
    border-radius: .5rem;
    background: var(--paper);
    box-shadow: var(--shadow);
    color: var(--ink);
    font-size: .74rem;
    font-weight: 650;
    line-height: 1.4;
}

/* Shared notes widget */
.notes-widget { max-width: 100%; }
.notes-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .65rem;
}
.notes-widget-heading { display: flex; align-items: center; gap: .55rem; }
.notes-count {
    display: inline-grid;
    min-width: 1.6rem;
    height: 1.6rem;
    padding: 0 .42rem;
    place-items: center;
    border: 1px solid #c4dceb;
    border-radius: 999px;
    background: #ddecf6;
    color: #245f91;
    box-shadow: none;
    font-family: var(--font-mono);
    font-size: .7rem;
    font-weight: 800;
    line-height: 1;
}
.notification-center { display: grid; gap: 2rem; }
.notification-area-upcoming { padding-top: 1.5rem; border-top: 1px solid var(--line); }
.notification-area-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .75rem;
}
.notification-upcoming-label {
    display: inline-flex;
    min-height: 1.65rem;
    align-items: center;
    padding: .2rem .55rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--paper);
    color: var(--ink-soft);
    font-size: .67rem;
    font-weight: 800;
    white-space: nowrap;
}
.notification-empty-state {
    min-height: 5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .65rem;
    padding: 1rem;
    border: 1px dashed var(--line);
    border-radius: .65rem;
    color: var(--ink-soft);
    font-size: .8rem;
}
.notification-empty-state svg {
    width: 1.15rem;
    height: 1.15rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.notes-add-button { display: inline-flex; align-items: center; gap: .35rem; }
.notes-composer {
    margin-bottom: .65rem;
    border: 1px solid var(--line);
    border-radius: .65rem;
    background: var(--paper);
    box-shadow: 0 4px 14px rgba(36, 42, 48, .045);
    overflow: hidden;
}
.notes-composer:not([hidden]) {
    animation: notes-composer-in .18s ease-out;
}
@keyframes notes-composer-in {
    from { opacity: 0; transform: translateY(-.25rem); }
    to { opacity: 1; transform: translateY(0); }
}
.notes-form-inner {
    padding: 1rem;
}
.notes-composer-title { margin-bottom: .85rem; color: var(--ink); font-size: .8rem; font-weight: 800; }
.notes-options {
    display: grid;
    grid-template-columns: minmax(0, 14rem) minmax(12rem, 1fr);
    align-items: end;
    gap: 1rem;
    flex: 1 1 30rem;
    min-width: 0;
}
.notes-urgent-switch {
    display: flex;
    align-items: center;
    gap: .55rem;
    min-height: 2rem;
    padding-left: 0;
}
.notes-urgent-switch .form-check-input { float: none; flex: none; }
@media (max-width: 767.98px) {
    .notes-options { grid-template-columns: minmax(0, 1fr); }
}
.notes-textarea {
    resize: vertical;
    min-height: 4.75rem;
    font-size: .86rem;
    line-height: 1.5;
}
.notes-list {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: .5rem;
    align-items: stretch;
}
.note-item {
    --note-surface: var(--paper);
    grid-column: span 12;
    height: 8.5rem;
    padding: .65rem .75rem;
    border: 1px solid var(--line);
    border-radius: .65rem;
    background: var(--note-surface);
    box-shadow: 0 2px 8px rgba(36, 42, 48, .025);
    transition: box-shadow .16s ease, border-color .16s ease, transform .16s ease;
}
.note-item.note-short { grid-column: span 4; }
.note-item.note-medium { grid-column: span 6; }
.note-item.is-expanded { height: auto; min-height: 8.5rem; }
.note-item > .d-flex { height: 100%; min-height: 0; }
.note-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}
.note-item.is-expanded > .d-flex,
.note-item.is-expanded .note-content { height: auto; }
.note-item .profile-avatar-md {
    width: 2rem !important;
    height: 2rem !important;
    min-width: 2rem;
    min-height: 2rem;
    max-width: 2rem;
    max-height: 2rem;
    flex: 0 0 2rem;
    overflow: hidden;
    font-size: .68rem;
    line-height: 1;
}
.note-item .profile-avatar-md > img {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: cover;
}
.note-item:hover {
    border-color: #b8c8d4;
    box-shadow: 0 4px 14px rgba(36, 42, 48, .06);
    transform: translateY(-1px);
}
.note-urgent {
    --note-surface: #b54343;
    border-color: transparent;
    background: var(--note-surface);
    color: #fff;
}
.note-urgent:hover {
    border-color: #762828;
    box-shadow: 0 5px 16px rgba(117, 32, 32, .24);
}
.note-urgent .note-author,
.note-urgent .note-body {
    color: #fff;
}
.note-tag {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    max-width: 100%;
    padding: .15rem .5rem;
    border: 1px solid transparent;
    border-radius: .35rem;
    font-family: var(--font-sans);
    font-size: .75rem;
    font-weight: 700;
    line-height: 1.4;
    overflow-wrap: anywhere;
}
.note-portal-badge {
    border-color: color-mix(in srgb, var(--primary-deep) 40%, transparent);
    background: var(--primary-soft);
    color: var(--primary-deep);
    max-width: min(100%, 9rem);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.note-urgent-icon { display: inline-flex; align-items: center; color: var(--danger); }
.note-urgent .note-urgent-icon { color: #fff; }
.note-urgent .note-tag {
    border-color: rgba(255, 255, 255, .5);
    background: rgba(255, 255, 255, .2);
    color: #fff;
}
.note-urgent .note-delete-btn {
    color: rgba(255, 255, 255, .82);
}
.note-urgent .note-delete-btn:hover {
    background: rgba(255, 255, 255, .16);
    color: #fff;
}
.note-body {
    position: relative;
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: .84rem;
    line-height: 1.5;
    color: var(--ink);
}
.note-body.is-truncated::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2.25em;
    pointer-events: none;
    background: linear-gradient(
        to bottom,
        color-mix(in srgb, var(--note-surface) 0%, transparent) 0%,
        color-mix(in srgb, var(--note-surface) 72%, transparent) 56%,
        var(--note-surface) 100%
    );
}
.note-item.is-expanded .note-body {
    display: block;
    overflow: visible;
}
.note-item.is-expanded .note-body::after { display: none; }
.note-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: none;
    min-height: 1.5rem;
    margin-top: auto;
    padding-top: .15rem;
}
.note-expand-btn {
    padding: .15rem 0;
    border: 0;
    background: transparent;
    color: var(--primary-deep);
    font-size: .72rem;
    font-weight: 800;
}
.note-expand-btn:hover { text-decoration: underline; }
.note-urgent .note-expand-btn { color: #fff; }
.note-delete-form { margin-left: auto !important; }
.note-delete-btn {
    display: grid;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: .38rem;
    background: transparent;
    color: var(--ink-soft);
    opacity: 0;
    transition: opacity .16s ease, background-color .16s ease, color .16s ease;
}
.note-item:hover .note-delete-btn,
.note-item:focus-within .note-delete-btn,
.note-delete-btn:focus-visible {
    opacity: 1;
}
.note-delete-btn:hover {
    background: color-mix(in srgb, var(--danger) 10%, transparent);
    color: var(--danger);
}
.notes-expiry-input {
    width: 14rem;
}
@media (prefers-reduced-motion: reduce) {
    .notes-composer:not([hidden]) { animation: none; }
    .note-item { transition: none; }
}

@media (max-width: 1099.98px) {
    .note-item.note-short { grid-column: span 6; }
}

@media (max-width: 767.98px) {
    .note-item.note-short,
    .note-item.note-medium,
    .note-item.note-long { grid-column: span 12; }
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e6e9ec;
  --ink-soft: #a7b1ba;
  --surface: #181b1f;
  --paper: #242a30;
  --line: #3a424a;
  --primary-soft: #1f3f5c;
  --primary-deep: #8fc5ee;
  --primary-light: #8fc5ee;
  --action-bg: #376f9d;
  --action-hover: #4380af;
  --action-pressed: #245f91;
  --action-outline-border: #6489a3;
  --action-outline-text: #c6dbe9;
  --action-outline-hover: #2c3c49;
  --action-outline-active: #345166;
  --danger: #f0a4a4;
  --warning: #ead18d;
  --led-active: #55e6a1;
  --led-invited: #83caff;
  --led-suspended: #ffc268;
  --led-archived: #b8c6d0;
  --led-deny: #ff7480;
  --led-allow: #55e6a1;
  --led-own: #ffc268;
  --shadow: 0 10px 28px rgba(0, 0, 0, .24);
}
html[data-theme="dark"] .topbar { background: rgba(36,42,48,.96); }
html[data-theme="dark"] a,
html[data-theme="dark"] .account-link,
html[data-theme="dark"] .nav-tabs .nav-link,
html[data-theme="dark"] .pagination .page-link {
  color: var(--primary-deep);
}
html[data-theme="dark"] a:hover,
html[data-theme="dark"] .account-link:hover,
html[data-theme="dark"] .nav-tabs .nav-link:hover,
html[data-theme="dark"] .pagination .page-link:hover {
  color: #c2e1fa;
}
html[data-theme="dark"] .text-secondary,
html[data-theme="dark"] .text-muted,
html[data-theme="dark"] .form-text,
html[data-theme="dark"] .text-body-secondary {
  color: var(--ink-soft) !important;
}
html[data-theme="dark"] .text-danger,
html[data-theme="dark"] .validation-summary-errors,
html[data-theme="dark"] .field-validation-error {
  color: #f0a4a4 !important;
}
html[data-theme="dark"] .text-success { color: #9bd6c8 !important; }
html[data-theme="dark"] .text-warning { color: #ead18d !important; }
html[data-theme="dark"] .form-label,
html[data-theme="dark"] label,
html[data-theme="dark"] legend {
  color: #d4d9dd;
}
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select {
  border-color: #46515b; background-color: #1e2328; color: var(--ink);
}
html[data-theme="dark"] .form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23d4d9dd' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}
html[data-theme="dark"] .form-control::placeholder,
html[data-theme="dark"] .form-select::placeholder { color: #9aa6af; }
html[data-theme="dark"] .form-select option,
html[data-theme="dark"] .form-control option {
  background-color: #1e2328;
  color: var(--ink);
}
html[data-theme="dark"] .form-control:disabled,
html[data-theme="dark"] .form-select:disabled,
html[data-theme="dark"] .form-check-input:disabled {
  background-color: #303840;
  color: #9aa6af;
  opacity: 1;
}
html[data-theme="dark"] .form-check-label { color: var(--ink); }
html[data-theme="dark"] .btn-primary:is(:link, :visited, :hover, :focus-visible, :active) { color: #fff; }
html[data-theme="dark"] .btn-outline-primary { border-color: var(--action-outline-border); color: var(--action-outline-text); }
html[data-theme="dark"] .btn-outline-primary:is(:hover, :focus-visible) {
  border-color: #8fabc2; background: var(--action-outline-hover); color: #e4f0f8;
}
html[data-theme="dark"] .btn-outline-primary:is(:active, .active, [aria-pressed="true"]) {
  border-color: #8fabc2; background: var(--action-outline-active); color: #fff;
}
html[data-theme="dark"] :is(.btn-secondary, .btn-outline-secondary) {
  border-color: #71818d; color: #d2dbe2;
}
html[data-theme="dark"] :is(.btn-secondary, .btn-outline-secondary):is(:hover, :focus-visible) {
  border-color: #9aaab5; background: #303b44; color: #edf2f5;
}
html[data-theme="dark"] :is(.btn-secondary, .btn-outline-secondary):is(:active, .active, [aria-pressed="true"]) {
  border-color: #9aaab5; background: #3c4953; color: #fff;
}
html[data-theme="dark"] .btn-danger {
  background: #a9464f;
  border-color: #a9464f;
  color: #fff;
}
html[data-theme="dark"] .btn-danger:hover,
html[data-theme="dark"] .btn-danger:focus-visible {
  background: #b75159;
  border-color: #b75159;
  color: #fff;
}
html[data-theme="dark"] .btn-danger:active,
html[data-theme="dark"] .btn-danger.active,
html[data-theme="dark"] .btn-danger[aria-pressed="true"] {
  background: #903942;
  border-color: #903942;
  color: #fff;
}
html[data-theme="dark"] .btn-outline-danger {
  background: transparent;
  border-color: #bd747b;
  color: #f2bec2;
}
html[data-theme="dark"] .btn-outline-danger:hover,
html[data-theme="dark"] .btn-outline-danger:focus-visible {
  border-color: #df9299;
  background: #472d33;
  color: #ffe0e2;
}
html[data-theme="dark"] .btn-outline-danger:active,
html[data-theme="dark"] .btn-outline-danger.active,
html[data-theme="dark"] .btn-outline-danger[aria-pressed="true"] {
  border-color: #df9299;
  background: #67383f;
  color: #fff;
}
html[data-theme="dark"] .btn:disabled,
html[data-theme="dark"] .btn.disabled {
  border-color: #59636d;
  background: #59636d;
  color: #e1e6ea;
}
html[data-theme="dark"] .alert-success { border-color: #286558; background: #1d3b35; color: #9bd6c8; }
html[data-theme="dark"] .alert-danger { border-color: #754343; background: #442a2a; color: #f0b8b8; }
html[data-theme="dark"] .alert-warning { border-color: #6e5a2a; background: #3e351f; color: #ead18d; }
html[data-theme="dark"] .alert-success *,
html[data-theme="dark"] .alert-danger *,
html[data-theme="dark"] .alert-warning * { color: inherit; }
html[data-theme="dark"] .card,
html[data-theme="dark"] .card-header,
html[data-theme="dark"] .table-responsive,
html[data-theme="dark"] .list-group-item,
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .modal-content {
  background-color: var(--paper);
  border-color: var(--line);
  color: var(--ink);
}
html[data-theme="dark"] .dropdown-item {
  color: var(--ink);
}
html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus {
  background-color: #303941;
  color: #fff;
}
html[data-theme="dark"] .dropdown-item.active,
html[data-theme="dark"] .dropdown-item:active {
  background-color: var(--primary-soft);
  color: #c2e1fa;
}
html[data-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--ink);
  --bs-table-border-color: var(--line);
  --bs-table-striped-bg: #2b3239;
  --bs-table-hover-bg: #303941;
}
html[data-theme="dark"] .table > :not(caption) > * > * {
  color: var(--ink);
  border-color: var(--line);
}
html[data-theme="dark"] .table thead th { color: var(--ink-soft); }
html[data-theme="dark"] .nav-tabs .nav-link.active {
  border-bottom-color: #8fc5ee;
  color: #b9ddf7;
}
html[data-theme="dark"] .page-link {
  background: var(--paper);
  border-color: var(--line);
  color: var(--primary-deep);
}
html[data-theme="dark"] .page-link:hover,
html[data-theme="dark"] .page-link:focus {
  background: var(--primary-soft);
  border-color: var(--primary-light);
  color: #c2e1fa;
}
html[data-theme="dark"] .page-item.disabled .page-link {
  background: #30363d;
  border-color: var(--line);
  color: #77838d;
}
html[data-theme="dark"] .border,
html[data-theme="dark"] .border-top,
html[data-theme="dark"] .border-end,
html[data-theme="dark"] .border-bottom,
html[data-theme="dark"] .border-start {
  border-color: var(--line) !important;
}
html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .bg-light,
html[data-theme="dark"] .bg-body {
  background-color: var(--paper) !important;
  color: var(--ink) !important;
}
html[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(1.8); }
html[data-theme="dark"] hr { border-color: var(--line); opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* BeNews Portals Grid & Cards */
.portals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr));
    gap: 1rem;
}
@media (min-width: 768px) {
    .portals-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
    }
}
@media (min-width: 1500px) {
    .portals-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.portal-section-heading { min-width: 0; }
.portal-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: .65rem;
    min-width: 0;
    max-width: 100%;
}

.portal-sort .btn,
.portal-search-form .form-control,
.portal-search-form .btn {
    min-height: 2.55rem;
    padding-top: .48rem;
    padding-bottom: .48rem;
    font-size: .82rem;
}

.portal-sort .btn {
    min-width: 5.6rem;
    font-weight: 800;
    border-color: var(--line);
    background: var(--paper);
    color: var(--ink-soft);
}
.portal-sort .btn:hover,
.portal-sort .btn:focus-visible {
    border-color: var(--primary-light);
    background: color-mix(in srgb, var(--primary-light) 10%, var(--paper));
    color: var(--primary-deep);
}
.portal-sort .btn[aria-pressed="true"] {
    border-color: color-mix(in srgb, var(--primary-light) 45%, var(--line));
    background: color-mix(in srgb, var(--primary-light) 16%, var(--paper));
    color: var(--primary-deep);
}

.portal-search-form {
    display: flex;
    align-items: stretch;
}

.portal-search-form .form-control {
    width: min(16rem, 30vw);
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.portal-search-form .btn {
    margin-left: -1px;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    font-weight: 800;
}

.portal-order-status {
    min-height: 1.25rem;
    color: var(--ink-soft);
}

.portal-card {
    display: flex;
    align-items: center;
    background: var(--paper);
    border: 1px solid var(--line);
    min-height: 6.25rem;
    border-radius: 0.7rem;
    padding: 1rem 1.15rem;
    position: relative;
    transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.portal-card:hover {
    border-color: var(--primary-light);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

html[data-theme="dark"] .portal-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.portal-card-drag-handle {
    display: none;
    cursor: grab;
    padding: 0.5rem 0.5rem 0.5rem 0;
    color: var(--ink-soft);
    margin-left: -0.5rem;
}

.portal-card-drag-handle:active {
    cursor: grabbing;
}

.portal-card-drag-handle:hover {
    color: var(--ink);
}

.portals-grid[data-sort-mode="custom"] .portal-card-drag-handle {
    display: flex;
}

.portals-grid[data-sort-mode="custom"] .portal-card-actions {
    display: flex;
}

.portal-card-main {
    flex: 1;
    min-width: 0;
}

.portal-card-info {
    flex: 1;
    min-width: 0;
}

.portal-card-name {
    display: block;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--ink);
    text-decoration: none;
    line-height: 1.2;
    margin-bottom: 0.2rem;
    overflow-wrap: anywhere;
}

.portal-card-name:hover {
    color: var(--primary);
    text-decoration: underline;
}

.portal-card-meta {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--ink-soft);
    white-space: nowrap;
    overflow: hidden;
}

.portal-card-meta .text-truncate {
    flex: 1;
    min-width: 0;
}

.meta-separator {
    opacity: 0.5;
}

.portal-card-stats {
    text-align: left;
    margin-left: 1rem;
    padding-left: 1rem;
    border-left: 1px solid var(--line);
    min-width: 8rem;
    flex-shrink: 0;
}

.sessions-source + .sessions-source {
    margin-top: .45rem;
}

.sessions-val {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.3rem;
    font-size: 1.18rem;
    line-height: 1;
    color: var(--ink);
}

.sessions-label {
    font-size: 0.62rem;
    color: var(--ink-soft);
    margin-top: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-family: var(--font-mono);
}

.sessions-unavailable {
    color: var(--ink-soft);
    font-size: .72rem;
    font-weight: 700;
    line-height: 1.25;
}

.trend-up { color: #2f9e65; }
.trend-down { color: #d14b4b; }
.trend-stable { color: var(--ink-soft); }
html[data-theme="dark"] .trend-up { color: #51c98a; }
html[data-theme="dark"] .trend-down { color: #f07d7d; }

.portal-card.is-dragging {
    opacity: 0.4;
    border: 1px dashed var(--primary);
}
.portal-card.drag-over {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-soft);
}

.portal-card-actions {
    display: none;
    flex-direction: column;
    gap: 0.2rem;
    margin-left: 0.5rem;
    flex-shrink: 0;
}

.btn-reorder {
    padding: 0.2rem;
    line-height: 1;
    background: transparent;
    border: 1px solid transparent;
    color: var(--ink-soft);
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.15s ease;
}
.btn-reorder:hover, .btn-reorder:focus-visible {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink);
}

.profile-avatar-sm { flex: 0 0 2.25rem; width: 2.25rem; height: 2.25rem; font-size: .8rem; }
.profile-avatar-sm img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

html[data-theme="dark"] .note-item:not(.note-urgent):hover {
  border-color: var(--primary-light);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
}
html[data-theme="dark"] .note-urgent:hover {
  border-color: #6f2424;
  box-shadow: 0 5px 18px rgba(0, 0, 0, .34);
}
html[data-theme="dark"] .note-item:not(.note-urgent) .note-delete-btn:hover {
  background: #2f1919;
  color: #f0a4a4;
}
html[data-theme="dark"] .note-urgent .note-delete-btn:hover {
  background: rgba(255, 255, 255, .2);
  color: #fff;
}
html[data-theme="dark"] .notes-count {
  border-color: rgba(255, 255, 255, .82);
  background: #fff;
  color: #242a30;
}

@media (max-width: 767.98px) {
  .portal-tools, .portal-search-form { width: 100%; }
  .portal-sort { display: flex; width: 100%; }
  .portal-sort .btn { flex: 1 1 0; min-width: 0; padding-inline: .3rem; font-size: .75rem; white-space: normal; }
  .portal-search-form .form-control { flex: 1; width: auto; min-width: 0; }
  .portal-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: .5rem;
    padding: .85rem;
  }
  .portals-grid[data-sort-mode="custom"] .portal-card {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }
  .portal-card-drag-handle { display: none !important; }
  .portal-card-main { grid-column: 1; grid-row: 1; min-width: 0; }
  .portal-card-main > .d-flex { gap: .55rem !important; }
  .portal-card-main > .d-flex > a { flex: 0 0 auto; }
  .portal-card-stats {
    grid-column: 2;
    grid-row: 1;
    min-width: 5.6rem;
    width: auto;
    margin: 0;
    padding: 0 0 0 .55rem;
    border-left: 1px solid var(--line);
    border-top: 0;
    text-align: left;
  }
  .portal-card-actions {
    grid-column: 3;
    grid-row: 1;
    flex-direction: column;
    justify-content: center;
    margin: 0;
    padding: 0;
    border: 0;
  }
  .btn-reorder { display: grid; place-items: center; min-width: 2rem; min-height: 2rem; padding: 0; }
}
@media (max-width: 480px) {
  .portal-card-stats {
    grid-column: 1 / -1;
    grid-row: 2;
    min-width: 0;
    padding: .7rem 0 0;
    margin-top: .7rem;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

/* ---- Granular permission matrix (task 23) ---- */
.gpm-card { padding: 0; overflow: hidden; }
.gpm-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.gpm-portal-picker { min-width: 15rem; }
.gpm-tile { width: 1.9rem; height: 1.9rem; font-size: .7rem; flex: none; }
.gpm-empty { padding: 1.4rem 1.2rem; }
.gpm-readonly { padding: .55rem 1.2rem; background: var(--primary-soft); color: var(--ink); }
.gpm-bulk { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)) auto; align-items: end; gap: .65rem; padding: .8rem; background: color-mix(in srgb, var(--primary-soft) 38%, var(--paper)); }
.gpm-bulk-field { min-width: 0; }
.gpm-bulk-field label { display: block; font-size: .75rem; font-weight: 600; margin-bottom: .25rem; }
.gpm-bulk .form-select { width: 100%; min-width: 0; min-height: 2.4rem; }
.gpm-bulk .btn { min-height: 2.4rem; }
.gpm-bulk-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .25rem 1rem; padding: .65rem .8rem; }
.gpm-bulk-count { font-weight: 600; }
.gpm-bulk-count.is-error { color: var(--danger); }
.gpm-bulk-hint { color: var(--ink-soft); grid-column: 1 / -1; }
.gpm-bulk-panel { margin: .55rem 1.2rem; border: 1px solid var(--line); border-radius: .5rem; overflow: hidden; }
.gpm-bulk-title { margin: 0; font-size: .85rem; font-weight: 700; }
.gpm-bulk-panel .gpm-bulk { border-top: 1px solid var(--line); border-bottom: 0; }
.gpm-group-summary { display: flex; align-items: center; gap: .75rem; padding: .65rem .8rem; color: var(--ink); font-weight: 600; cursor: pointer; list-style: none; }
.gpm-group-summary::-webkit-details-marker { display: none; }
.gpm-group-summary::after { content: ""; width: .5rem; height: .5rem; flex: none; margin-left: auto; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translateY(-2px); transition: transform .15s ease; }
.gpm-group[open] > .gpm-group-summary::after { transform: rotate(225deg); }
.gpm-group-name { display: inline-flex; align-items: center; gap: .4rem; }
.gpm-group { margin: .55rem 1.2rem; border: 1px solid var(--line); border-radius: .5rem; overflow: hidden; }
.gpm-group-summary { background: color-mix(in srgb, var(--primary-soft) 55%, var(--paper)); }
.gpm-group-tools { padding: .45rem .8rem; border-top: 1px solid var(--line); }
.gpm-group-select { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; }
.gpm-group-select .form-check-input, .gpm-select-hit .form-check-input { float: none; margin: 0; width: .8rem; height: .8rem; flex: 0 0 .8rem; }
.gpm-scroll { overflow-x: auto; max-height: 72vh; }
.gpm-table { font-size: .82rem; border-collapse: separate; border-spacing: 0; min-width: 62rem; --bs-table-bg: transparent; color: var(--ink); }
.gpm-table thead th { position: sticky; top: 0; z-index: 2; background: var(--paper); font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); font-weight: 600; white-space: nowrap; border-bottom: 1px solid var(--line); padding: .5rem .45rem; }
.gpm-table td, .gpm-table tbody th { padding: .32rem .45rem; vertical-align: top; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.gpm-sel { width: 2rem; text-align: center; }
.gpm-select-hit { display: inline-flex; align-items: center; justify-content: center; min-width: 2rem; min-height: 2rem; cursor: pointer; }
.gpm-area-col { min-width: 12rem; }
.gpm-group-row th { background: color-mix(in srgb, var(--primary-soft) 70%, var(--paper)); color: var(--primary-deep); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; padding: .4rem .6rem; position: sticky; left: 0; }
.gpm-group-count { font-weight: 500; color: var(--ink-soft); }
.gpm-area { font-weight: 600; position: sticky; left: 0; background: var(--paper); z-index: 1; }
.gpm-area-name { display: block; line-height: 1.9rem; }
.gpm-area-name[for] { margin: 0; cursor: pointer; color: inherit; font-weight: inherit; }
.gpm-inactive { display: none; font-size: .68rem; font-weight: 500; color: var(--warning); }
.gpm-row.is-inactive .gpm-inactive { display: block; }
.gpm-row.is-inactive .gpm-area-name { color: var(--ink-soft); }
.gpm-row.is-inactive .gpm-cell:not(:nth-child(3)) .gpm-select { opacity: .72; }
.gpm-row.is-selected td, .gpm-row.is-selected .gpm-area { background: color-mix(in srgb, var(--primary-soft) 55%, var(--paper)); }
.gpm-row.has-error .gpm-area { box-shadow: inset 1px 0 0 var(--danger); }
.gpm-errors { list-style: none; margin: 0; padding: 0; font-size: .72rem; font-weight: 500; color: var(--danger); max-width: 16rem; }
.gpm-errors li + li { margin-top: .15rem; }
.gpm-cell { min-width: 6.4rem; }
.gpm-cell-label { display: block; font-size: .66rem; color: var(--ink-soft); line-height: 1.1; margin-bottom: .1rem; }
.gpm-select { font-size: .8rem; padding-top: .18rem; padding-bottom: .18rem; min-width: 5.2rem; }
.gpm-select.is-scope { min-width: 7.6rem; }
.gpm-select-control { display: flex; align-items: center; gap: .35rem; }
.gpm-select-control .gpm-select { flex: 1 1 auto; min-width: 0; }
.gpm-value-deny { background: var(--led-deny); }
.gpm-value-allow { background: var(--led-allow); }
.gpm-value-own { background: var(--led-own); }
.gpm-cell.is-dirty .gpm-select { border-color: var(--primary-light); box-shadow: inset 0 -2px 0 var(--primary-light); }
.gpm-select.is-invalid { border-color: var(--danger); }
.gpm-na { color: var(--ink-soft); text-align: center; line-height: 1.9rem; }
.gpm-help { display: inline-grid; place-items: center; width: .95rem; height: .95rem; border-radius: 50%; border: 1px solid currentColor; font-size: .6rem; cursor: help; margin-left: .2rem; }
.gpm-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .8rem; padding: .75rem 1.2rem; border-top: 1px solid var(--line); }
.gpm-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.gpm-status { color: var(--primary-deep); font-weight: 600; }
.gpm-status.is-error { color: var(--danger); }
html[data-theme="dark"] .gpm-group-row th { color: var(--ink); background: color-mix(in srgb, var(--primary) 22%, var(--paper)); }
html[data-theme="dark"] .gpm-status { color: var(--primary-light); }
html[data-theme="dark"] .gpm-bulk, html[data-theme="dark"] .gpm-readonly { background: color-mix(in srgb, var(--primary) 12%, var(--paper)); }
html[data-theme="dark"] .gpm-row.is-selected td, html[data-theme="dark"] .gpm-row.is-selected .gpm-area { background: color-mix(in srgb, var(--primary) 18%, var(--paper)); }
@media (max-width: 767.98px) {
  .gpm-head, .gpm-foot { padding: .8rem; }
  .gpm-portal-picker { width: 100%; }
  .gpm-area-col { min-width: 9rem; }
  .gpm-group { margin-left: .8rem; margin-right: .8rem; }
  .gpm-bulk-panel { margin-left: .8rem; margin-right: .8rem; }
  .gpm-bulk { grid-template-columns: minmax(0,1fr); }
  .gpm-bulk .btn { width: 100%; min-height: 2.75rem; }
  .gpm-bulk .form-select { min-height: 2.75rem; }
  .gpm-scroll { max-height: none; overflow: visible; }
  .gpm-table { min-width: 0; width: 100%; }
  .gpm-table thead { display: none; }
  .gpm-table tbody { display: block; }
  .gpm-row { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .45rem .65rem; padding: .65rem; background: var(--paper); border-bottom: 1px solid var(--line); }
  .gpm-table > tbody > .gpm-row > * { background: transparent; border: 0; box-shadow: none; }
  html[data-theme="dark"] .gpm-table > tbody > .gpm-row > * { background: transparent; }
  .gpm-row.is-selected { background: color-mix(in srgb, var(--primary-soft) 55%, var(--paper)); }
  html[data-theme="dark"] .gpm-row.is-selected { background: color-mix(in srgb, var(--primary) 18%, var(--paper)); }
  .gpm-row > .gpm-sel { grid-column: 1; grid-row: 1; width: 1.5rem; padding: 0; justify-self: start; position: relative; z-index: 1; }
  .gpm-row > .gpm-sel:empty { display: none; }
  .gpm-row > .gpm-sel:empty + .gpm-area { grid-column: 1 / -1; }
  .gpm-select-hit { min-width: 1.5rem; min-height: 2.75rem; justify-content: flex-start; padding-left: .375rem; }
  .gpm-row > .gpm-area { grid-column: 1 / -1; grid-row: 1; position: static; z-index: auto; padding: .3rem 0 .3rem 1.5rem; align-self: center; }
  .gpm-row > .gpm-sel:empty + .gpm-area { padding-left: 0; }
  .gpm-row.has-error > .gpm-area { border-left: 1px solid var(--danger); box-shadow: none; }
  .gpm-row > .gpm-cell { min-width: 0; padding: 0; }
  .gpm-row > .gpm-cell::before { content: attr(data-label); display: block; color: var(--ink-soft); font-size: .72rem; font-weight: 600; margin-bottom: .2rem; }
  .gpm-row > .gpm-na { display: none; }
  .gpm-row .gpm-select-control .gpm-select, .gpm-row .gpm-select-control .gpm-select.is-scope { width: auto; min-width: 0; }
}
@media (max-width: 359.98px) {
  .gpm-row { grid-template-columns: minmax(0,1fr); }
  .gpm-row > .gpm-cell { grid-column: 1; }
}

/* Portal analytics */
.analytics-page-header {
  padding: 0 0 1.2rem;
  border-bottom: 1px solid var(--line);
}
.analytics-page-header h1 { margin-bottom: .3rem; letter-spacing: -.035em; }
.analytics-chart-card {
  --chart-inset: clamp(1rem, 2vw, 1.5rem);
  padding: 0; overflow: hidden;
}
.analytics-chart-card > h2 {
  margin: 0 var(--chart-inset) 1rem;
  padding-top: var(--chart-inset);
}
.analytics-chart-card > .analytics-filters,
.analytics-chart-card > p,
.analytics-chart-card > .analytics-daily-details,
.analytics-chart-card > .analytics-no-data {
  margin-left: var(--chart-inset);
  margin-right: var(--chart-inset);
}
.analytics-chart-card > .analytics-daily-details,
.analytics-chart-card > .analytics-no-data { margin-bottom: var(--chart-inset); }
.analytics-preview { container: analytics-preview / inline-size; }
.analytics-preview-grid, .analytics-panel-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.analytics-preview-source, .analytics-panel {
  background: var(--paper);
  border: 1px solid var(--line); border-radius: .65rem; padding: 1.1rem; min-width: 0;
}
.analytics-preview-source { container: analytics-preview-source / inline-size; }
.analytics-preview-periods { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.analytics-preview-period + .analytics-preview-period { border-top: 1px solid var(--line); padding-top: 1rem; }
.analytics-period-label { font-size: .75rem; font-weight: 700; color: var(--ink-soft); margin-bottom: .55rem; }
.analytics-preview-period { container: analytics-preview-period / inline-size; min-width: 0; }
.analytics-preview-measures { display: grid; grid-template-columns: minmax(0, 1fr); gap: .7rem; }
.analytics-preview-metric { text-align: left; min-width: 0; font-variant-numeric: tabular-nums; }
.analytics-preview-metric .sessions-val { flex-wrap: wrap; }
@container analytics-preview (min-width: 900px) {
  .analytics-preview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container analytics-preview-source (min-width: 820px) {
  .analytics-preview-periods { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-preview-period + .analytics-preview-period {
    border-top: 0; border-left: 1px solid var(--line); padding-top: 0; padding-left: 1rem;
  }
}
@container analytics-preview-period (min-width: 350px) {
  .analytics-preview-measures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.analytics-filters {
  display: flex; align-items: flex-end; gap: .75rem; flex-wrap: wrap;
  padding: 1rem; border: 1px solid var(--line); border-radius: .65rem;
  background: var(--paper);
}
.analytics-filters label { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; min-width: 10rem; }
.analytics-filters .form-select { background-color: var(--paper); }
.analytics-filters .btn { min-height: 2.4rem; }
.analytics-chart-frame {
  position: relative; width: 100%; min-width: 0;
  height: clamp(220px, 28vw, 320px); overflow: hidden;
}
.analytics-chart-canvas { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: pan-y; }
.analytics-chart-canvas:focus-visible { outline: 2px solid var(--primary); outline-offset: -3px; }
.analytics-chart-tooltip {
  position: absolute; z-index: 1; min-width: 8rem; padding: .45rem .65rem;
  border: 1px solid var(--line); border-radius: .45rem; background: var(--paper);
  color: var(--ink); box-shadow: var(--shadow); pointer-events: none;
  font-family: var(--font-sans); font-size: .8rem; line-height: 1.4;
}
.analytics-chart-tooltip > span { display: block; color: var(--ink-soft); }
.analytics-chart-tooltip > strong { display: block; font-weight: 700; }
.analytics-chart-script-note { margin: .75rem var(--chart-inset); color: var(--ink-soft); }
.analytics-no-data { padding: 3rem 1rem; text-align: center; border: 1px dashed var(--line); border-radius: .6rem; color: var(--ink-soft); }
.analytics-chart-table { max-height: 18rem; overflow-y: auto; }
.analytics-daily-details > .analytics-chart-table { margin-top: .75rem; }
.analytics-daily-details { font-family: var(--font-sans); font-size: inherit; }
.analytics-daily-details > summary {
  display: inline-flex; align-items: center; gap: .5rem;
  color: var(--primary-deep); font-weight: 600; cursor: pointer; list-style: none;
  text-decoration: underline; text-underline-offset: 3px;
}
.analytics-daily-details > summary::marker { content: ""; }
.analytics-daily-details > summary::-webkit-details-marker { display: none; }
.analytics-daily-details > summary::after {
  content: ""; width: .46rem; height: .46rem; flex: none;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px); transition: transform .16s ease;
}
.analytics-daily-details[open] > summary::after { transform: rotate(225deg) translate(-1px, -1px); }
.analytics-daily-details > summary:hover { color: var(--primary); }
html[data-theme="dark"] .analytics-daily-details > summary:hover { color: #c2e1fa; }
.analytics-daily-details > summary:focus-visible { outline: 2px solid var(--primary-light); outline-offset: 3px; }
.analytics-breakdown > h2 { margin-bottom: 1rem !important; }
.analytics-source-section { container: analytics-source / inline-size; }
.analytics-source-section > h2, .analytics-source-section > h3 { letter-spacing: -.012em; }
.analytics-panel h3, .analytics-panel h4 { font-weight: 750; }
.analytics-metric {
  border-top: 1px solid var(--line); padding: .65rem 0; text-align: left; font-variant-numeric: tabular-nums;
}
.analytics-metric:last-child { padding-bottom: 0; }
.analytics-metric .sessions-val { flex-wrap: wrap; }
.analytics-delta { display: block; margin-top: .3rem; font-size: .72rem; font-weight: 700; }
.analytics-table-delta { display: block; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.network-tile-stat .analytics-delta { font-size: .65rem; }
.analytics-network-table { border: 1px solid var(--line); border-radius: .65rem; }
.analytics-network-table .table { margin-bottom: 0; }
.analytics-network-table thead { background: color-mix(in srgb, var(--primary) 6%, var(--paper)); }
.analytics-network-table th, .analytics-network-table td { padding: .7rem .9rem; vertical-align: middle; }
.analytics-network-portals .network-tile-grid { margin-top: 1.1rem; }
.dashboard-stats-card .analytics-preview-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 385px), 1fr)); gap: .75rem;
}
.dashboard-stats-card .analytics-preview-source { padding: .85rem; }
.dashboard-stats-card .analytics-preview-periods { gap: .65rem; }
.dashboard-stats-card .analytics-preview-period + .analytics-preview-period { padding-top: .65rem; }
.dashboard-stats-card .analytics-period-label { margin-bottom: .35rem; }
.dashboard-facebook .analytics-panel-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
.dashboard-facebook .analytics-panel {
  padding: .35rem 0; border: 0; border-radius: 0; background: transparent;
}
.dashboard-facebook .analytics-panel + .analytics-panel {
  border-top: 1px solid var(--line); margin-top: .65rem; padding-top: .85rem;
}
.dashboard-facebook .analytics-panel h3 { margin-bottom: .5rem !important; }
.dashboard-facebook .analytics-metric { padding: 0; border: 0; }
.dashboard-facebook .analytics-metric + .analytics-metric {
  margin-top: .7rem; padding-top: .65rem; border-top: 1px solid var(--line);
}
.dashboard-facebook .analytics-delta { margin-top: .2rem; }
@container analytics-source (min-width: 620px) {
  .dashboard-facebook .analytics-panel-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-facebook .analytics-panel { padding: .35rem .85rem; }
  .dashboard-facebook .analytics-panel:first-child { padding-left: 0; }
  .dashboard-facebook .analytics-panel:last-child { padding-right: 0; }
  .dashboard-facebook .analytics-panel + .analytics-panel {
    border-top: 0; border-left: 1px solid var(--line);
    margin-top: 0; padding-top: .35rem;
  }
}
@container analytics-source (min-width: 460px) {
  .analytics-panel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container analytics-source (min-width: 620px) {
  .analytics-panel-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .analytics-filters label { width: 100%; }
  .analytics-filters .btn { width: 100%; }
}
.network-tile-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: .75rem;
}
.network-tile {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  min-width: 0; padding: .9rem; border: 1px solid var(--line); border-radius: .6rem;
  background: color-mix(in srgb, var(--primary) 4%, var(--paper));
  color: var(--ink); text-decoration: none;
  transition: border-color .16s ease, background-color .16s ease;
}
.network-tile:hover, .network-tile:focus-visible {
  border-color: var(--primary); color: var(--ink);
  background: color-mix(in srgb, var(--primary) 9%, var(--paper));
}
.network-tile:not([href]) { cursor: default; }
.network-tile:not([href]):hover { border-color: var(--line); }
.network-tile-identity { display: flex; align-items: center; gap: .6rem; min-width: 0; flex: 1; }
.network-tile-identity .portal-tile { flex: 0 0 auto; }
.network-tile-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.network-tile-stat { flex: 0 0 auto; min-width: 5.5rem; }
.network-tile .sessions-val { font-size: 1rem; }
.network-tile .sessions-label { display: block; font-size: .58rem; }
@media (max-width: 520px) {
  .portal-page-heading > .notes-add-button { width: 100%; justify-content: center; }
}
@media (max-width: 360px) {
  .network-tile { flex-wrap: wrap; }
  .network-tile-stat { width: 100%; padding-left: 3rem; }
}
/* iOS ingrandisce automaticamente i controlli con testo inferiore a 16px al focus. */
@media (max-width: 767.98px) {
  input:not(:is([type="checkbox"], [type="radio"], [type="file"], [type="hidden"],
    [type="color"], [type="range"], [type="submit"], [type="button"], [type="reset"])),
  select,
  textarea { font-size: 16px !important; }
}
