:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --brand-green: #53a650;
  --radius: 10px;
  --font: system-ui, "Segoe UI", Roboto, sans-serif;
  --sidebar-bg: #151c28;
  --nav-active-bg: rgba(88, 166, 255, 0.15);
  color-scheme: dark;
}
html[data-theme="light"],
html[data-theme="system"] {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --border: #d0d7de;
  --text: #1f2328;
  --muted: #656d76;
  --accent: #0969da;
  --sidebar-bg: #f3f6f9;
  --nav-active-bg: rgba(9, 105, 218, 0.12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    --bg: #0d1117;
    --surface: #161b22;
    --border: #30363d;
    --text: #e6edf3;
    --muted: #8b949e;
    --accent: #58a6ff;
    --sidebar-bg: #151c28;
    --nav-active-bg: rgba(88, 166, 255, 0.15);
    color-scheme: dark;
  }
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f6f8fa;
    --surface: #ffffff;
    --border: #d0d7de;
    --text: #1f2328;
    --muted: #656d76;
    --accent: #0969da;
    --sidebar-bg: #f3f6f9;
    --nav-active-bg: rgba(9, 105, 218, 0.12);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.ui-frame { display: flex; min-height: 100vh; }
.ui-main-column { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  padding: 1rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
  z-index: 40;
  overflow: visible;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: inherit;
  text-decoration: none;
}

.site-brand-mark {
  width: 2.35rem;
  height: 2.35rem;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 0.18rem;
}

.site-brand-archiv { color: var(--brand-green); }
.sidebar-nav { display: flex; flex-direction: column; gap: 1rem; }
.nav-hint {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 50;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 22%, var(--surface));
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.3;
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}
.nav-hint:hover { border-color: var(--accent); }
.nav-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0.25rem 0.35rem 0.15rem;
}

a.nav-item {
  display: block;
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  text-decoration: none;
}

.nav-tip {
  position: relative;
  display: block;
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: default;
}
.nav-tip:hover,
.nav-tip:focus-visible { background: var(--nav-active-bg); outline: none; }
.nav-tip p {
  position: absolute;
  left: calc(100% + 0.7rem);
  top: 0;
  z-index: 30;
  width: 18.5rem;
  margin: 0;
  padding: 0.85rem 0.95rem;
  text-align: left;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
}
.nav-tip:hover p,
.nav-tip:focus-visible p { opacity: 1; visibility: visible; }

a.nav-item:hover,
a.nav-item.active { background: var(--nav-active-bg); }
a.nav-item.active { color: var(--accent); font-weight: 600; }

.ui-scope-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.65rem 1.25rem 0.35rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.ui-scope-tab {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 0.32rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 500;
}
.ui-scope-tab[hidden] { display: none; }
.ui-scope-tab[data-scope="mandate"].active { border-color: rgba(88, 166, 255, 0.55); background: rgba(88, 166, 255, 0.12); color: light-dark(#0969da, #79b8ff); }
.ui-scope-tab[data-scope="memberships"].active { border-color: rgba(63, 185, 80, 0.5); background: rgba(63, 185, 80, 0.1); color: light-dark(#1a7f37, #56d364); }
.ui-scope-tab[data-scope="platform"].active { border-color: rgba(227, 179, 65, 0.55); background: rgba(227, 179, 65, 0.1); color: light-dark(#9a6700, #e3b341); }
body.guest .ui-scope-tabs { display: none; }
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1.25rem;
  background: var(--surface);
  flex-wrap: wrap;
}
.app-header-main { position: relative; flex: 1; min-width: 0; }
.app-header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem 0.85rem;
  flex-shrink: 0;
  max-width: 100%;
}
.header-identity-cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  min-width: 0;
}
#account { display: flex; align-items: center; gap: 0.65rem 0.85rem; }
.header-mandate-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.header-mandate-chevron { flex-shrink: 0; font-size: 0.75rem; color: var(--muted); line-height: 1; }
.header-mandate-chevron[hidden] { display: none; }
.role-badge {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(88, 166, 255, 0.15);
  border: 1px solid rgba(88, 166, 255, 0.4);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
}
.role-badge[hidden] { display: none; }
.mandate-menu { position: absolute; top: 100%; left: 0; z-index: 30; display: flex; flex-direction: column; width: max-content; min-width: min(28rem, calc(100vw - 16px)); max-width: min(42rem, calc(100vw - 16px)); max-height: calc(100vh - 6.5rem); margin-top: 0.35rem; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); padding: 0; }
.mandate-menu[hidden] { display: none; }
.header-mandate-menu-search { flex-shrink: 0; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); }
.header-mandate-menu-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.4rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
.header-mandate-menu-search-input:focus { outline: 2px solid rgba(88, 166, 255, 0.35); border-color: var(--accent); }
.header-mandate-menu-list { overflow-y: auto; padding: 0.25rem 0; }
.header-mandate-menu-empty { padding: 0.45rem 0.75rem; color: var(--muted); font-size: 0.82rem; }
.mandate-menu .row-action-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: none;
  border-radius: 0;
  font-weight: 400;
  font-size: 0.82rem;
  padding: 0.45rem 0.75rem;
}
.mandate-menu .row-action-menu-item:hover { background: rgba(88, 166, 255, 0.1); }
.mandate-menu .row-action-menu-item--current { font-weight: 600; color: var(--accent); }
.header-mandate-menu-label { min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.header-primary-title { margin: 0; font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; }
#logout {
  flex-shrink: 0;
  background: transparent;
  color: #f85149;
  border: 1px solid #f85149;
  border-radius: 4px;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
}
.user-trigger { background: transparent; color: var(--muted); border: none; padding: 0; font-size: 0.85rem; font-weight: 500; text-align: right; max-width: 14rem; word-break: break-all; }
.user-trigger:hover { color: var(--accent); }

.content { padding: 1.25rem; max-width: 920px; }
.content.wide { max-width: none; }
body.guest .app-header { display: none; }
body.guest .content { max-width: none; flex: 1; display: flex; }
.hero { margin: auto; text-align: center; max-width: 42rem; }
.hero-logo { width: min(15.5rem, 70vw); height: auto; background: #fff; border-radius: 16px; padding: 1rem 1.15rem 0.85rem; }
.hero-actions { display: flex; gap: 0.65rem; justify-content: center; margin-top: 1.75rem; }
#dlg-login .dlg-body { padding: 1rem; }
#dlg-login .field { margin: 0 0 0.85rem; }
#dlg-login .lp-forgot { text-align: right; margin: -0.2rem 0 0.55rem; }
#dlg-login .dlg-msg { margin: 0 0 0.75rem; }
#dlg-login .btn-row { margin: 1rem 0 0; }
#dlg-login #login-submit { background: #c9d1d9; color: #1f2328; border: 1px solid #c9d1d9; border-radius: 8px; padding: 0.5rem 1rem; font-weight: 600; }
#login-totp[hidden] { display: none; }
#login-totp-enroll[hidden] { display: none; }
.lp-totp-qr { width: 11.5rem; height: 11.5rem; margin: 0.2rem 0 0.65rem; padding: 0.35rem; background: #fff; border-radius: 8px; }
.lp-totp-qr svg { width: 100%; height: 100%; display: block; }
.lp-totp-secret { margin: 0 0 0.75rem; color: var(--muted); font-family: ui-monospace, Consolas, monospace; font-size: 0.78rem; letter-spacing: 0.04em; word-break: break-all; }
.auswertung-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.auswertung-logo { width: auto; max-width: 9rem; height: 2.6rem; object-fit: contain; margin-left: auto; }
.row-remove { position: absolute; top: 0.35rem; right: 0.35rem; width: 1.5rem; height: 1.5rem; padding: 0; border: none; border-radius: 4px; background: transparent; color: #f85149; font-size: 1.35rem; line-height: 1; }
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.panel + .panel { margin-top: 0.8rem; }
.muted { color: var(--muted); }
button, input, select, textarea {
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
}
button { background: var(--accent); color: #0d1117; border: none; cursor: pointer; font-weight: 600; }
form.stack, fieldset { display: flex; flex-direction: column; gap: 0.55rem; align-items: stretch; }
fieldset { position: relative; border: 1px solid var(--border); border-radius: 8px; padding: 0.7rem; margin: 0; }
label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; color: var(--muted); }
table { width: 100%; border-collapse: collapse; margin-top: 0.8rem; }
td, th { border-bottom: 1px solid var(--border); text-align: left; padding: 0.35rem 0.4rem; font-size: 0.9rem; }
ul { padding-left: 1.1rem; }

#ba-login { position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, 0.45); }
#ba-login[hidden] { display: none !important; }
#ba-login iframe { width: 100%; height: 100%; border: 0; background: transparent; color-scheme: normal; }
dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  max-width: 22rem;
  width: calc(100% - 2rem);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.72); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); font-weight: 600; }
.dlg-close { background: none; border: none; color: var(--muted); font-size: 1.25rem; cursor: pointer; }
.dlg-body { padding: 0 0 1rem; }
.field { margin: 0 1rem 0.85rem; text-align: left; }
.field label { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 0.25rem; }
.field input, .dlg-body select { width: 100%; }
.hint, .lp-forgot, .dlg-msg { margin: 0 1rem 0.75rem; font-size: 0.82rem; color: var(--muted); }
.lp-forgot button { color: var(--accent); background: none; border: none; padding: 0; text-decoration: underline; cursor: pointer; }
.btn-row { display: flex; justify-content: flex-end; gap: 0.5rem; margin: 0 1rem; }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.step-nav { display: flex; gap: 0.75rem; justify-content: flex-start; margin-top: 1rem; }
.add-link { background: none; border: none; color: var(--accent); padding: 0.15rem 0; font-weight: 500; text-align: left; }
.add-link:hover { text-decoration: underline; }
label small { font-weight: 400; font-size: 0.78rem; }
.dlg-msg.err { color: light-dark(#cf222e, #ffa198); }
.dlg-msg.ok { color: #7ee787; }

.sheet-tools { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; margin: 0.5rem 0 1rem; }
.sheet-tools label { display: grid; gap: 0.25rem; font-size: 0.78rem; color: var(--muted); }
.sheet-tools label[hidden] { display: none; }
.sheet-tools select, .sheet-tools input { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 0.4rem 0.5rem; }
.chart-plan-title { margin: 1.15rem 0 0.55rem; padding-bottom: 0.35rem; border-bottom: 2px solid var(--accent); color: var(--text); font-size: 1.08rem; font-weight: 700; }
.chart-plan-title:first-child { margin-top: 0.2rem; }
.chart-search { display: grid; gap: 0.35rem; margin: 0.15rem 0 1rem; color: var(--text); font-size: 1rem; font-weight: 700; }
.chart-search input { font-size: 1.15rem; padding: 0.8rem 0.95rem; border: 2px solid var(--accent); background: var(--bg); }
.sheet-tools { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; margin: 0 0 1rem; }
.pill-btn { border-radius: 999px; padding: 0.4rem 0.9rem; align-self: end; }
.plan-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 0.75rem; }
.plan-tag { display: inline-flex; align-items: center; gap: 0.15rem; max-width: 100%; border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--border)); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border-radius: 999px; padding: 0.12rem 0.2rem 0.12rem 0.15rem; }
.plan-tag.is-active { background: color-mix(in srgb, var(--accent) 28%, var(--surface)); }
.plan-tag-name, .plan-tag-remove { background: none; color: var(--text); border: none; border-radius: 999px; font-weight: 600; }
.plan-tag-name { padding: 0.15rem 0.35rem 0.15rem 0.55rem; text-align: left; }
.plan-tag-remove { width: 1.35rem; height: 1.35rem; padding: 0; color: var(--muted); line-height: 1; }
.plan-tag-remove:hover { color: var(--text); background: color-mix(in srgb, var(--text) 8%, transparent); }
.sheet-wrap { overflow: visible; }
table.sheet { width: auto; border-collapse: collapse; font-size: 0.82rem; table-layout: fixed; user-select: none; -webkit-user-select: none; }
.sheet th, .sheet td { min-width: 0; border-bottom: 1px solid var(--border); padding: 0.35rem 0.5rem; text-align: left; vertical-align: top; white-space: normal; overflow: visible; overflow-wrap: anywhere; }
.facts { width: auto; }
.facts th { width: 16rem; text-align: left; font-weight: 600; padding: 0.2rem 0.8rem 0.2rem 0; vertical-align: top; }
.facts td { padding: 0.2rem 0; }
.sheet th { position: sticky; top: 0; background: #006699; color: #fff; cursor: default; }
.col-menu { position: fixed; z-index: 40; min-width: 16rem; max-width: 22rem; max-height: 70vh; overflow: auto; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 0.65rem 0.8rem; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28); }
.col-menu-title { margin: 0 0 0.4rem; font-weight: 700; }
.col-menu label { display: flex; gap: 0.45rem; align-items: flex-start; padding: 0.18rem 0; }
.col-menu input { margin-top: 0.2rem; }
.col-menu button { margin-top: 0.55rem; }
.col-resize { position: absolute; top: 0; right: 0; width: 8px; height: 100%; cursor: col-resize; touch-action: none; }
.searchterm { display: none; }
.searchterm.hit { display: inline; margin-right: 0.35rem; }
.tip { display: inline-block; margin-left: 0.35rem; width: 1rem; height: 1rem; border: none; border-radius: 50%; background: var(--accent); color: #0d1117; text-align: center; font-size: 0.7rem; line-height: 1rem; padding: 0; cursor: default; }
#tip-pop { position: fixed; z-index: 80; width: max-content; max-width: min(36rem, calc(100vw - 16px)); margin: 0; padding: 0.7rem 0.8rem; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45); font-size: 0.82rem; line-height: 1.35; }
#tip-pop a { color: var(--accent); cursor: pointer; text-decoration: underline; }
#dlg-account { max-width: 28rem; }
#account-totp-setup[hidden], #account-totp-disable[hidden], #account-platform[hidden] { display: none; }
#dlg-account .check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.2rem;
  padding: 0;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text);
}
#dlg-account input[type="checkbox"] {
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}
#dlg-account .field .hint {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
}
#account-totp-confirm, #account-totp-disable-btn { margin-top: 0.55rem; }
.pw2 { margin-top: 0.65rem; }
.pw-rules { margin: 0.45rem 0 0; padding-left: 1.1rem; color: var(--muted); font-size: 0.78rem; }
.pw-rules .met { color: #1a7f37; }
.branch-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 0.8rem; }
.check-list { max-height: 16rem; overflow: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.check { display: flex; gap: 0.45rem; align-items: flex-start; padding: 0.4rem 0.55rem; color: var(--text); font-weight: 400; }
.check small, .check em { color: var(--muted); font-style: normal; }
.account-grid { display: grid; grid-template-columns: 1fr 1fr; }
.account-grid .span2 { grid-column: 1 / -1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.grid2[hidden] { display: none; }
.wide { grid-column: 1 / -1; }
.card { margin: 0.2rem 0; padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.text-link { background: none; color: var(--accent); border: none; padding: 0; font: inherit; cursor: pointer; }
.mandate-kind { display: flex; gap: 1rem; margin-bottom: 0.7rem; }
.mandate-card { margin: 0.7rem 0; padding: 0.8rem 0.9rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.mandate-card.is-current { border-color: var(--accent); }
.mandate-card h3 { margin: 0 0 0.2rem; }
.mandate-meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.45rem 1rem; margin: 0.5rem 0; }
.mandate-meta span { display: block; color: var(--muted); font-size: 0.75rem; }
.mandate-meta code { overflow-wrap: anywhere; }
.mandate-members { margin: 0.2rem 0 0; padding-left: 1.1rem; }
.suggest { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 8px; overflow: auto; max-height: 14rem; }
.suggest[hidden] { display: none !important; }
.suggest button { background: var(--bg); color: var(--text); border: 0; border-bottom: 1px solid var(--border); border-radius: 0; text-align: left; font-weight: 400; }
.err { color: light-dark(#cf222e, #ffa198); min-height: 1.2em; }
tr.best td { background: rgba(83, 166, 80, 0.18); font-weight: 600; }
.post { border-top: 1px solid var(--border); padding: 0.7rem 0; }
.post header { color: var(--muted); font-size: 0.8rem; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }

.nav-drawer-toggle { display: none; }
.nav-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0.45);
}
.nav-drawer-overlay.nav-drawer-overlay--visible { display: block; }

@media (max-width: 900px) {
  body:not(.guest) .nav-drawer-toggle {
    display: inline-flex;
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: center;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 3.75rem;
    padding: 0 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
  }
  body:not(.guest) .app-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 0.55rem;
    row-gap: 0.35rem;
    padding: 0.55rem 0.75rem;
  }
  body:not(.guest) .app-header-main { grid-column: 2; grid-row: 1; }
  body:not(.guest) .header-identity-cluster { flex-wrap: nowrap; gap: 0.4rem 0.5rem; }
  body:not(.guest) .header-mandate-trigger { min-width: 0; }
  body:not(.guest) .app-header-actions {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
    max-width: none;
    justify-content: space-between;
  }
  body:not(.guest) #account { width: 100%; justify-content: space-between; }
  body:not(.guest) .user-trigger {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    word-break: normal;
    font-size: 0.82rem;
  }
  body:not(.guest) .header-primary-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  body:not(.guest) .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 88vw);
    z-index: 200;
    transform: translateX(-102%);
    transition: transform 0.2s ease;
    overflow-y: auto;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
  }
  body:not(.guest) .sidebar.sidebar--open { transform: translateX(0); }
  body:not(.guest) a.nav-item { min-height: 44px; }
  body.guest .ui-frame { flex-direction: column; }
  body.guest .sidebar { width: auto; }
}

.kr-firms h2 { margin-top: 0; }
.kr-kind { display: flex; align-items: center; gap: 1rem; }
.kr-kind label { flex-direction: row; align-items: center; gap: 0.35rem; color: var(--text); }
.kr-kind button, .kr-menu, .kr-toolbar > button, .kr-perms-head button, .kr-perms-user { background: none; border: none; color: var(--text); font-weight: 400; }
.kr-kind button { margin-left: auto; }
#mandate-form-body { margin-top: 0.8rem; }
.kr-form-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.8rem; }
.kr-list-head { display: flex; justify-content: space-between; align-items: baseline; margin-top: 1.2rem; }
.kr-list-head h3 { margin: 0; }
.kr-help { font-size: 0.82rem; margin: 0.35rem 0 0.6rem; }
.kr-toolbar { display: flex; align-items: center; gap: 0.6rem; }
.kr-sort { margin: 0.4rem 0 0.6rem; }
.kr-card { display: flex; gap: 0.55rem; align-items: flex-start; border: 1px solid var(--border); border-radius: 10px; padding: 0.65rem 0.75rem; margin: 0.55rem 0; background: var(--surface); }
.kr-card.is-current { border-color: var(--accent); }
.kr-check { display: flex; align-items: center; }
.kr-card-body { flex: 1; min-width: 0; }
.kr-card-title { font-weight: 600; font-size: 0.95rem; padding: 0; }
.kr-seat { font-size: 0.82rem; }
.kr-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(16rem, 34rem); gap: 0.75rem; margin-top: 0.45rem; }
.kr-label { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted); margin: 0.15rem 0; }
.kr-meta { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 0.45rem 0.75rem; padding: 0.55rem 0.65rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.kr-meta code { font-size: 0.72rem; }
.kr-member { display: flex; gap: 0.45rem; align-items: center; font-size: 0.85rem; }
.kr-ok { color: #3fb950; }
.kr-pills { display: flex; gap: 0.5rem; margin-top: 0.45rem; }
.kr-pill { border-radius: 999px; padding: 0.28rem 0.85rem; background: color-mix(in srgb, var(--accent) 18%, var(--surface)); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--border)); font-size: 0.78rem; font-weight: 600; }
.kr-perms { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-start; justify-content: center; padding: 2rem 1rem; background: rgba(0, 0, 0, 0.72); }
.kr-perms[hidden] { display: none; }
.kr-perms-panel { width: min(40rem, 100%); max-height: calc(100vh - 4rem); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0.85rem 1rem 1rem; }
.kr-perms-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.kr-perms-head button { font-size: 1.25rem; color: var(--muted); }
.kr-perms-layout { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); border: 1px solid var(--border); border-radius: 10px; min-height: 12rem; margin: 0.6rem 0; }
.kr-perms-user { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left; padding: 0.4rem 0.5rem; }
.kr-perms-user.is-active { background: color-mix(in srgb, var(--accent) 22%, transparent); }
#kr-perms-detail { padding: 0.7rem 0.8rem; }
.kr-role, .kr-app label { display: flex; flex-direction: row; align-items: center; gap: 0.35rem; color: var(--text); font-size: 0.85rem; }
.kr-role { gap: 0.8rem; margin-bottom: 0.7rem; }
.kr-app { border-top: 1px solid var(--border); padding-top: 0.55rem; margin-top: 0.55rem; }
.kr-app-head { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 0.35rem; }
.kr-badge { font-size: 0.72rem; color: var(--muted); font-weight: 500; }
.kr-badge.on { color: #3fb950; }
@media (max-width: 760px) {
  .kr-detail, .kr-meta, .kr-perms-layout { grid-template-columns: 1fr; }
}
body:has(.content.embed) .ui-main-column {
  height: 100vh;
  overflow: hidden;
}
.content.embed {
  max-width: none;
  flex: 1;
  min-height: 0;
  padding: 0;
  display: flex;
  overflow: hidden;
}
.kr-embed-frame {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: transparent;
}
