/* ==============================================================
   Clausal — shared shell styles
   Used by app.js to render sidebar + user menu + toasts on every
   screen. Designed to coexist with the inline styles in each page.
   ============================================================== */

/* ------------------- SIDEBAR (overrides .side from each page) */
.cl-side {
  background: oklch(98% 0.005 240);
  border-right: 1px solid var(--c-border);
  display: flex; flex-direction: column;
  align-items: center;
  padding: 10px 0;
}
.cl-side__brand {
  width: 36px; height: 36px;
  margin-bottom: 14px;
  background: url('assets/clausal-icon.svg') center/contain no-repeat;
}
.cl-side__nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.cl-side__item {
  width: 44px; height: 44px;
  border-radius: var(--r-6);
  display: flex; align-items: center; justify-content: center;
  color: var(--c-text-3);
  cursor: pointer;
  position: relative;
  flex-direction: column;
  gap: 2px;
  font-size: 9px; font-weight: var(--fw-medium);
  letter-spacing: 0.02em;
  text-decoration: none;
}
.cl-side__item:hover { background: var(--c-surface-3); color: var(--c-text); }
.cl-side__item.is-active {
  background: var(--c-primary-50);
  color: var(--c-primary-700);
}
.cl-side__item.is-active::before {
  content: ""; position: absolute;
  left: -10px; top: 8px; bottom: 8px; width: 2px;
  background: var(--c-primary-600);
  border-radius: 0 2px 2px 0;
}
.cl-side__item.is-disabled {
  color: var(--c-text-4);
  cursor: not-allowed;
  opacity: 0.55;
  pointer-events: none;
}
.cl-side__icon {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
}
.cl-side__count {
  position: absolute; top: 4px; right: 4px;
  min-width: 16px; height: 14px; padding: 0 4px;
  background: var(--c-primary-600); color: #fff;
  font-size: 9px; font-weight: var(--fw-semibold);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-variant-numeric: tabular-nums;
}

.cl-side__user {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 8px 0;
  border-top: 1px solid var(--c-border);
  width: 44px;
  cursor: pointer;
  outline: none;
}
.cl-side__avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: oklch(70% 0.10 30); color: #fff;
  font-size: 11px; font-weight: var(--fw-semibold);
  display: flex; align-items: center; justify-content: center;
}

/* ------------------- HEADER RIGHT (bell + help + user menu) */
.cl-header-right {
  display: flex; align-items: center; gap: 4px;
  justify-self: end;
}
.cl-icon-btn {
  position: relative;
  width: 32px; height: 32px;
  border-radius: var(--r-6);
  background: transparent;
  border: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--c-text-2);
  cursor: pointer;
}
.cl-icon-btn:hover { background: var(--c-surface-3); color: var(--c-text); }
.cl-icon-btn__dot {
  position: absolute; top: 4px; right: 4px;
  min-width: 14px; height: 14px; padding: 0 3px;
  background: var(--c-danger-600); color: #fff;
  font-size: 9px; font-weight: var(--fw-semibold);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-variant-numeric: tabular-nums;
  border: 1.5px solid var(--c-surface);
}
.cl-user-btn {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px;
  padding: 2px 8px 2px 4px;
  margin-left: 4px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-8);
  cursor: pointer;
  font-family: inherit;
}
.cl-user-btn:hover { background: var(--c-surface-3); border-color: var(--c-border); }
.cl-user-btn.is-open { background: var(--c-surface-3); border-color: var(--c-border); }
.cl-user-btn__avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: oklch(70% 0.10 30); color: #fff;
  font-size: 11px; font-weight: var(--fw-semibold);
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
}
.cl-user-btn__meta {
  display: flex; flex-direction: column;
  align-items: flex-start;
  text-align: left;
  line-height: 1.2;
}
.cl-user-btn__name { font-size: var(--fs-13); font-weight: var(--fw-semibold); color: var(--c-text); }
.cl-user-btn__role { font-size: 10px; color: var(--c-text-3); margin-top: 1px; }
.cl-user-btn__caret { color: var(--c-text-3); font-size: 10px; }
.cl-user-pop--header {
  left: auto !important;
  right: 0 !important;
  bottom: auto !important;
  top: calc(100% + 6px) !important;
  display: none;
}
.cl-user-wrap.is-open .cl-user-pop--header,
.cl-user-btn.is-open + .cl-user-pop--header { display: block; }

/* ------------------- USER POPOVER */
.cl-user-pop {
  display: none;
  position: absolute;
  left: calc(100% + 8px);
  bottom: 4px;
  width: 220px;
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-8);
  box-shadow: var(--sh-lg);
  padding: 4px;
  z-index: 100;
  animation: cl-pop-in 120ms var(--ease-out);
}
.cl-side__user.is-open .cl-user-pop { display: block; }

@keyframes cl-pop-in {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cl-user-pop__head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px 10px 8px;
  border-bottom: 1px solid var(--c-divider);
  margin-bottom: 4px;
}
.cl-user-pop__avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: oklch(70% 0.10 30); color: #fff;
  font-size: 12px; font-weight: var(--fw-semibold);
  display: flex; align-items: center; justify-content: center;
}
.cl-user-pop__name { font-size: var(--fs-13); font-weight: var(--fw-semibold); color: var(--c-text); }
.cl-user-pop__role { font-size: 11px; color: var(--c-text-3); }

.cl-user-pop__item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  font-size: var(--fs-13);
  color: var(--c-text);
  border-radius: var(--r-4);
  text-decoration: none;
  cursor: pointer;
}
.cl-user-pop__item:hover { background: var(--c-surface-3); }
.cl-user-pop__item--danger { color: var(--c-danger-700); }
.cl-user-pop__item--danger svg { color: var(--c-danger-700); }
.cl-user-pop__item svg { color: var(--c-text-3); flex: none; }

.cl-user-pop__sep { height: 1px; background: var(--c-divider); margin: 4px 0; }

/* ------------------- TOAST */
.cl-toast-host {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column-reverse; gap: 8px;
  z-index: 9999;
  pointer-events: none;
}
.cl-toast {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--c-text);
  color: oklch(98% 0.003 240);
  font-size: var(--fs-13); font-weight: var(--fw-medium);
  border-radius: var(--r-6);
  box-shadow: var(--sh-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
  pointer-events: auto;
  min-width: 240px;
}
.cl-toast.is-in { opacity: 1; transform: translateY(0); }
.cl-toast__icon {
  width: 18px; height: 18px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: var(--fw-bold);
  background: var(--c-success-500); color: #fff;
  flex: none;
}
.cl-toast--warn .cl-toast__icon { background: var(--c-warning-500); color: oklch(20% 0.02 80); }
.cl-toast--info .cl-toast__icon { background: var(--c-info-500); color: #fff; }

/* ------------------- MODAL */
.cl-modal-host {
  position: fixed; inset: 0;
  background: var(--c-overlay);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
  animation: cl-fade-in 160ms var(--ease-out);
}
@keyframes cl-fade-in { from { opacity: 0 } to { opacity: 1 } }
.cl-modal {
  background: var(--c-surface);
  border-radius: var(--r-12);
  box-shadow: var(--sh-lg);
  width: 480px;
  max-width: calc(100vw - 48px);
  animation: cl-pop-in 200ms var(--ease-out);
  overflow: hidden;
}
.cl-modal__head {
  padding: 20px 24px 8px;
}
.cl-modal__title {
  font-size: var(--fs-18); font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}
.cl-modal__sub {
  font-size: var(--fs-13); color: var(--c-text-3);
}
.cl-modal__body { padding: 14px 24px 8px; }
.cl-modal__foot {
  padding: 14px 24px 18px;
  display: flex; justify-content: flex-end; gap: 8px;
  background: var(--c-surface-2);
  border-top: 1px solid var(--c-divider);
}


/* ============================================================
   Notification dropdown
   ============================================================ */
.cl-notif-pop {
  position: absolute;
  top: calc(100% + 6px); right: 0;
  width: 360px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-8);
  box-shadow: var(--sh-md);
  z-index: 80;
  opacity: 0; pointer-events: none; transform: translateY(-4px);
  transition: opacity 120ms, transform 120ms;
}
.cl-bell-wrap.is-open .cl-notif-pop { opacity: 1; pointer-events: auto; transform: translateY(0); }
.cl-notif-pop__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 8px;
  font-size: 13px; font-weight: 600;
  color: var(--c-text);
  border-bottom: 1px solid var(--c-divider);
}
.cl-notif-pop__count {
  font-size: 11px; font-weight: 600;
  background: var(--c-primary-50); color: var(--c-primary-700);
  padding: 1px 7px; border-radius: var(--r-full);
  font-variant-numeric: tabular-nums;
}
.cl-notif-pop__list { max-height: 360px; overflow: auto; }
.cl-notif-pop__foot {
  padding: 10px 14px;
  border-top: 1px solid var(--c-divider);
  font-size: 12px;
  text-align: right;
}
.cl-notif-pop__foot a {
  color: var(--c-text-3); text-decoration: none;
}
.cl-notif-pop__foot a:hover { color: var(--c-text); text-decoration: underline; }

.cl-notif-item {
  display: grid;
  grid-template-columns: 12px 1fr 22px;
  gap: 10px;
  padding: 10px 14px;
  align-items: start;
  font-size: 13px;
  border-bottom: 1px solid var(--c-divider);
}
.cl-notif-item:last-child { border-bottom: 0; }
.cl-notif-item:hover { background: var(--c-surface-2); }
.cl-notif-item__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--c-text-3);
  margin-top: 5px;
}
.cl-notif-item--warn    .cl-notif-item__dot { background: var(--c-warning-500); }
.cl-notif-item--info    .cl-notif-item__dot { background: var(--c-primary-500); }
.cl-notif-item--neutral .cl-notif-item__dot { background: var(--c-text-3); }
.cl-notif-item__body { cursor: pointer; }
.cl-notif-item__title { font-weight: 500; color: var(--c-text); line-height: 1.35; }
.cl-notif-item__sub   { font-size: 12px; color: var(--c-text-3); margin-top: 2px; line-height: 1.45; }
.cl-notif-item__x {
  width: 22px; height: 22px;
  background: none; border: 0; border-radius: var(--r-4);
  color: var(--c-text-3); cursor: pointer;
  font-family: inherit; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: -2px;
}
.cl-notif-item__x:hover { background: var(--c-surface-3); color: var(--c-text); }
.cl-notif-empty {
  padding: 28px 14px;
  text-align: center;
  font-size: 13px; color: var(--c-text-3);
}

/* ============================================================
   User menu pages (Profile / Notif settings / Preferences / Help)
   ============================================================ */
.cl-page-overlay {
  position: fixed; inset: 0;
  background: oklch(20% 0.01 240 / 0.55);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 180ms;
  z-index: 110;
  padding: 24px;
}
.cl-page-overlay.is-open { opacity: 1; pointer-events: auto; }
.cl-page {
  background: var(--c-surface);
  border-radius: var(--r-12);
  box-shadow: var(--sh-lg);
  width: 560px; max-width: 100%;
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  transform: translateY(8px) scale(0.985);
  transition: transform 180ms;
}
.cl-page-overlay.is-open .cl-page { transform: translateY(0) scale(1); }
.cl-page__head {
  display: flex; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--c-border);
}
.cl-page__head h2 { margin: 0; font-size: 16px; font-weight: var(--fw-semibold); flex: 1; }
.cl-page__close {
  width: 28px; height: 28px;
  background: none; border: 1px solid var(--c-border); border-radius: var(--r-4);
  cursor: pointer; color: var(--c-text-3); font-family: inherit;
  font-size: 18px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.cl-page__close:hover { background: var(--c-surface-2); color: var(--c-text); }
.cl-page__body { padding: 20px 22px 24px; overflow: auto; }

/* --- Profile --- */
.cl-profile {
  display: flex; align-items: center; gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--c-divider);
  margin-bottom: 18px;
}
.cl-profile__av {
  width: 56px; height: 56px; border-radius: 50%;
  background: oklch(70% 0.10 30); color: #fff;
  font-size: 18px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.cl-profile__name { font-size: 18px; font-weight: var(--fw-semibold); color: var(--c-text); letter-spacing: -0.01em; }
.cl-profile__role { font-size: 13px; color: var(--c-text-2); margin-top: 2px; }
.cl-profile__org  { font-size: 12px; color: var(--c-text-3); font-family: var(--font-mono); margin-top: 4px; }

.cl-kv { display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.cl-kv__row { display: grid; grid-template-columns: 140px 1fr; align-items: baseline; gap: 12px; }
.cl-kv__k { color: var(--c-text-3); font-size: 12px; }
.cl-kv__v { color: var(--c-text); }

/* --- Toggle --- */
.cl-toggle {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 14px;
  align-items: start;
  padding: 14px 0;
  cursor: pointer;
  border-bottom: 1px solid var(--c-divider);
}
.cl-toggle:last-child { border-bottom: 0; }
.cl-toggle input { display: none; }
.cl-toggle__sw {
  width: 36px; height: 20px;
  background: var(--c-border-strong);
  border-radius: 999px;
  position: relative;
  transition: background 160ms;
}
.cl-toggle__sw::after {
  content: ""; position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%; background: #fff;
  transition: transform 160ms;
  box-shadow: 0 1px 2px oklch(20% 0.01 240 / 0.25);
}
.cl-toggle input:checked + .cl-toggle__sw { background: var(--c-primary-600); }
.cl-toggle input:checked + .cl-toggle__sw::after { transform: translateX(16px); }
.cl-toggle__txt { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.cl-toggle__txt b { font-weight: var(--fw-semibold); color: var(--c-text); }
.cl-toggle__txt span { color: var(--c-text-3); font-size: 12px; line-height: 1.5; }

/* --- Segmented control --- */
.cl-pref { padding: 14px 0; border-bottom: 1px solid var(--c-divider); }
.cl-pref:last-child { border-bottom: 0; }
.cl-pref__head { font-size: 11px; font-weight: var(--fw-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--c-text-3); margin-bottom: 8px; }
.cl-pref__hint { font-size: 12px; color: var(--c-text-3); margin-top: 6px; }
.cl-seg {
  display: inline-flex;
  padding: 3px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-6);
}
.cl-seg button {
  padding: 5px 14px;
  font-size: 12px; font-weight: var(--fw-medium);
  background: transparent; border: 0; border-radius: var(--r-4);
  color: var(--c-text-2); cursor: pointer; font-family: inherit;
}
.cl-seg button.is-on { background: var(--c-surface); color: var(--c-text); box-shadow: var(--sh-xs); }

/* --- Help --- */
.cl-help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.cl-help-grp__head { font-size: 11px; font-weight: var(--fw-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--c-text-3); margin-bottom: 8px; }
.cl-help-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; color: var(--c-text-2); }
.cl-help-row span:first-child { flex: 1; }
.cl-help-foot { margin-top: 16px; font-size: 12px; color: var(--c-text-3); }

/* --- QA report --- */
.cl-qa__row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.cl-qa__card { padding: 12px 14px; background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: var(--r-6); }
.cl-qa__lbl { font-size: 11px; color: var(--c-text-3); font-weight: var(--fw-medium); letter-spacing: var(--tracking-caps); text-transform: uppercase; }
.cl-qa__val { font-size: 22px; font-weight: var(--fw-semibold); letter-spacing: -0.015em; margin-top: 4px; color: var(--c-text); }
.cl-qa__sub { font-size: 12px; color: var(--c-text-3); margin-top: 2px; }
.cl-qa h3 { font-size: 13px; margin: 16px 0 6px; }
.cl-qa ul { margin: 0; padding-left: 18px; }
.cl-qa li { font-size: 13px; line-height: 1.6; color: var(--c-text-2); margin-bottom: 4px; }

/* ============================================================
   Compact density (set on body by Preferences)
   ============================================================ */
body.density-compact table.q tbody td { height: 24px; padding: 4px 16px; }
body.density-compact table.q thead th { padding: 6px 16px; }
body.density-compact .claim-cell__id   { font-size: 12px; }
body.density-compact .claim-cell__meta { font-size: 11px; }
body.density-compact .prov-cell__name  { font-size: 13px; }
body.density-compact .prov-cell__meta  { font-size: 11px; }
body.density-compact .pri-flag         { font-size: 12px; }
body.density-compact .rec-text         { font-size: 12px; }
