/* perf-extras.css — KC Performance KCDS overrides + layout helpers. PER-784.
 *
 * Loads AFTER @kc/k2 kcds.css so these rules win the cascade.
 *
 * The BRAND IS NOT SET HERE. KC Performance indigo comes from
 * <html data-kcds-product-category="perform"> in k2.html, which kcds.css maps to
 * the indigo ramp (#4F46E5 …) natively in both light and dark. Do NOT redeclare
 * --kcds-color-primary here — keep the single source of truth declarative.
 *
 * Use this file ONLY for:
 *   1. KC-Performance-specific KCDS token tweaks (rare), and
 *   2. layout/utility classes K2 has no component for (the AntD Row/Col/Space
 *      replacements land here as flex/grid utilities, per the port checklist).
 */

/* Base page reset so the static app fills the viewport (no Vite/React reset). */
html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--kcds-color-surface-canvas, #fff);
  color: var(--kcds-color-text-primary, #1f2937);
  font-family: var(--kcds-font-family, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
}

/* The router renders pages into this container inside the shell. */
.perf-outlet {
  display: block;
  min-height: 0;
}

/* Layout utilities (AntD Space/Row/Col replacements). Extend as clusters need. */
.perf-row {
  display: flex;
  gap: var(--kcds-spacing-16, 16px);
}
.perf-col {
  display: flex;
  flex-direction: column;
  gap: var(--kcds-spacing-12, 12px);
}
.perf-stack {
  display: flex;
  flex-direction: column;
  gap: var(--kcds-spacing-8, 8px);
}

/* ────────────────────────────────────────────────────────────────────────────
 * App shell — composed of <k2-app-shell> + <k2-app-sidebar> + <k2-app-header>
 * SDK components (PER-774 trial). The custom .perf-shell flex layout from the
 * round-1 port is GONE; the SDK now owns grid / scroll / collapsing-region
 * behavior. What lives here:
 *   - <k2-app-sidebar> bg/border overrides (LMS-Admin rule: white sidebar)
 *   - .perf-brand block slotted into k2-app-sidebar's `brand-head` slot
 *   - .perf-nav (still styled here — k2 doesn't ship a nav list component)
 *   - .perf-header right-side controls slotted into k2-app-header's `end` slot
 *
 * Colors keep the kcds.css perform indigo. Density flips to compact via
 * <html data-kcds-density="compact"> set in k2.html — k2 components react
 * to that via :host-context.
 */

perf-app-shell {
  display: block;
  height: 100vh;
}

/* LMS-Admin sidebar rule: white #FFFFFF, never tinted. */
.perf-sidebar {
  background: #ffffff;
  border-inline-end: 1px solid var(--kcds-color-border-subtle, #e5e7eb);
}
[data-kcds-theme='dark'] .perf-sidebar {
  background: var(--kcds-color-surface-canvas, #0b1220);
  border-color: var(--kcds-color-border-subtle, #1f2937);
}

/* PER-815 — the PER-800 dark-theme override on k2-button[variant="default"]
 * was a workaround for a non-existent SDK variant. js-kc-k2/src/k2ui.js
 * defines only primary / neutral / tertiary / success / warning / danger
 * variants — `default` falls through to base button styles, which on dark
 * theme leaves the button transparent. Switching every caller to
 * `variant="neutral"` (KCDS canonical quiet button) lets the SDK style the
 * correct dark-theme contrast natively, so this override is gone. */

.perf-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 4px 0;
  color: var(--kcds-color-text-primary, #1f2937);
}
.perf-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.perf-brand-line1 {
  font-size: 14px;
  font-weight: 700;
}
.perf-brand-line2 {
  font-size: 12px;
  font-weight: 700;
  color: var(--kcds-color-primary, #4f46e5);
}

.perf-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.perf-nav-group {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--kcds-color-text-secondary, #6b7280);
  padding: 12px 8px 4px;
}
.perf-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  min-height: 36px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 400;
  color: var(--kcds-color-text-primary, #1f2937);
  text-decoration: none;
  transition:
    background 120ms ease,
    color 120ms ease;
}
.perf-nav-item:hover {
  background: var(--kcds-color-surface-canvas, rgba(79, 70, 229, 0.06));
  color: var(--kcds-color-text-primary, #1f2937);
}
.perf-nav-item.is-active {
  background: var(--kcds-color-primary-tint, rgba(79, 70, 229, 0.12));
  /* KCDS active text is on-primary-tint, but this CDN build resolves it to a
     light indigo (#A5B4FC) that fails contrast on the pale tint; primary reads
     correctly and is on-brand, so keep it. Weight is 700 (KCDS uses only 400/700). */
  color: var(--kcds-color-primary, #4f46e5);
  font-weight: 700;
}
/* Active-item accent bar at the inline-start edge (redesign mockup). */
.perf-nav-item.is-active::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--kcds-color-primary, #4f46e5);
  border-start-end-radius: 3px;
  border-end-end-radius: 3px;
}
.perf-nav-icon {
  display: inline-flex;
  width: 18px;
  justify-content: center;
  flex-shrink: 0;
}
.perf-nav-label {
  flex: 1;
  overflow: hidden;
  /* PER-804 — wrap to 2 lines for languages whose strings overflow the rail
   * (Spanish "Escalas de calificación" is the canonical too-long case). The
   * line-clamp shape is the standard 4-property block ellipsis pattern. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}
:lang(en) .perf-nav-label,
:lang(ar) .perf-nav-label {
  display: block;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.perf-nav-empty {
  padding: 12px 10px;
  font-size: 13px;
  color: var(--kcds-color-text-tertiary, #9ca3af);
}

/* <k2-app-header> own its 46-56px row. We only style the controls we slot
 * into its `end` slot. */
.perf-header {
  --k2-app-header-height: 46px;
}
.perf-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-inline-end: 16px;
}
.perf-iconbtn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--kcds-color-text-secondary, #4b5563);
  width: 32px;
  height: 32px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.perf-iconbtn:hover {
  background: var(--kcds-color-surface-canvas, rgba(0, 0, 0, 0.06));
  color: var(--kcds-color-text-primary, #1f2937);
}
.perf-lang {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  color: var(--kcds-color-text-secondary, #4b5563);
}
.perf-lang:hover {
  background: var(--kcds-color-surface-canvas, rgba(0, 0, 0, 0.06));
}
.perf-lang-select {
  appearance: none;
  border: 0;
  background: transparent;
  /* Theme-adaptive so the control text and the native option popup are
     readable in dark mode (was `inherit`, which left light text on the
     browser's default light popup). */
  color: var(--kcds-color-text-primary, #1f2937);
  font: inherit;
  cursor: pointer;
  padding-inline-end: 4px;
}
.perf-lang-select option {
  background: var(--kcds-color-surface-elevated, #fff);
  color: var(--kcds-color-text-primary, #1f2937);
}
.perf-lang-icon {
  display: inline-flex;
}
.perf-user {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: var(--kcds-color-surface-subtle, #f3f4f6);
  color: var(--kcds-color-text-primary, #1f2937);
}
[data-kcds-theme='dark'] .perf-user {
  background: var(--kcds-color-surface-subtle, #1f2937);
}
.perf-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--kcds-color-primary, #4f46e5);
  color: var(--kcds-color-on-primary, #fff);
  font-size: 12px;
  font-weight: 600;
}
.perf-user-name {
  font-size: 13px;
  font-weight: 600;
}
.perf-logout {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--kcds-color-text-secondary, #6b7280);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.perf-logout:hover {
  color: var(--kcds-color-primary, #4f46e5);
}

/* Router target — fills the <k2-app-shell> content slot. */
.perf-outlet-host {
  display: block;
  min-width: 0;
  min-height: 0;
  padding: 20px 24px;
  background: var(--kcds-color-surface-subtle, #f3f7f9);
  /* Establish a positioning context for the routed page. k2-data-table renders
   * a visually-hidden `position:absolute` screen-reader live-region (.dt__sr)
   * that has NO positioned ancestor inside the SDK shadow tree — so without
   * this it resolves its containing block to the initial containing block
   * (<html>) and anchors at its flow position, inflating documentElement's
   * scrollHeight past the viewport. That produced a second (document-level)
   * scrollbar and a tall band of empty space below the app shell, because the
   * shell's own [part=content] region can only clip normal-flow descendants,
   * not an absolute element anchored to the ICB. Making the outlet host a
   * containing block pulls those SR regions back inside the scrollable content
   * region, where they are clipped like everything else. */
  position: relative;
}

/* ────────────────────────────────────────────────────────────────────────────
 * Cluster 10 — employee dashboard (design-parity layout, PER-843).
 * The dashboard mockup's `.row-2col` is an asymmetric grid (main + fixed
 * 360px rail) that <k2-grid> can't express (it only does equal / auto-fit
 * columns), so the layout lives here as a tokenised class — same template the
 * mockup uses. Everything else on the page is real K2 components.
 * ──────────────────────────────────────────────────────────────────────────*/
.dash-2col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: var(--k2-space-24, 24px);
  align-items: start;
}
@media (max-width: 1200px) {
  .dash-2col {
    grid-template-columns: minmax(0, 1fr);
  }
}
.dash-main,
.dash-rail {
  display: flex;
  flex-direction: column;
  gap: var(--k2-space-24, 24px);
  min-width: 0;
}
.dash-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--k2-space-16, 16px);
  width: 100%;
}
.dash-panel-title {
  margin: 0;
  font-size: var(--k2-font-size-lg, 18px);
  font-weight: 600;
  color: var(--k2-color-text-primary);
}
.dash-panel-sub {
  margin-top: 2px;
  font-size: var(--k2-font-size-sm, 14px);
  color: var(--k2-color-text-secondary);
}
/* Row primary cell — leading icon bubble + title/meta (reviews, training). */
.dash-cellprimary {
  display: flex;
  align-items: center;
  gap: var(--k2-space-12, 12px);
}
.dash-cellprimary__ico {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--k2-radius-8, 8px);
  background: var(--k2-color-surface-subtle, #f3f7f9);
  color: var(--k2-color-text-tertiary, #74838a);
}
.dash-cellprimary__ico k2-icon {
  --k2-icon-size: 16px;
}
.dash-cellprimary__title {
  font-weight: 600;
  color: var(--k2-color-text-primary);
}
.dash-cellprimary__meta {
  font-size: var(--k2-font-size-sm, 14px);
  color: var(--k2-color-text-secondary);
}
/* Goal-completion ring block in the rail. */
.dash-goal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--k2-space-20, 20px);
  padding: var(--k2-space-8, 8px) 0;
}
.dash-goalstats {
  display: flex;
  width: 100%;
  justify-content: space-around;
  text-align: center;
}
.dash-goalstats__n {
  font-size: var(--k2-font-size-xl, 24px);
  font-weight: 700;
  color: var(--k2-color-text-primary);
}
.dash-goalstats__l {
  font-size: var(--k2-font-size-sm, 14px);
  color: var(--k2-color-text-secondary);
}
/* Card-header rows that carry an icon + title (goals / AI insight). */
.dash-ai-head {
  display: flex;
  align-items: center;
  gap: var(--k2-space-8, 8px);
  width: 100%;
}
.dash-ai-title {
  font-size: var(--k2-font-size-lg, 18px);
  font-weight: 600;
  color: var(--k2-color-text-primary);
}

/* PER-795 — focused (public) shell variant. Vertically + horizontally center
 * the page contents (login card etc.). `display: grid` with place-items keeps
 * the card's own width intact (login card uses max-width:420px). Min-height
 * ensures vertical centering even on a short login surface.
 *
 * PER-808 — `box-sizing: border-box` makes the explicit 24px padding part
 * of the `min-height: 100%` computation instead of stacking on top. With
 * the default `content-box`, this outlet's intrinsic block-size was
 * `100% + 48px` (top+bottom padding) relative to the K2 shell main area,
 * pushing the bottom edge ~48px past the viewport. The browser then
 * painted an empty scrollbar gutter (visible as up/down arrows on the
 * page edge in RTL where the gutter flips left) even though no content
 * was actually scrollable. `border-box` collapses padding into the
 * min-height envelope. */
.perf-outlet-host--centered {
  box-sizing: border-box;
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 24px;
}
.perf-outlet-host--centered .perf-outlet {
  width: 100%;
}
.perf-header-brand {
  display: flex;
  align-items: center;
  padding-inline-start: 16px;
}

/* PER-798 — mobile shell.
 *
 * Desktop: hamburger hidden, k2-app-sidebar visible.
 * <lg (≤ 1023px): k2-app-sidebar hidden, hamburger shown in header start,
 *                 k2-drawer holds the same brand + nav content.
 *
 * k2-drawer ships focus-trap / ESC / backdrop / body-scroll-lock, and its
 * `placement="start"` is a LOGICAL property — it auto-flips under
 * [dir="rtl"] (slides from the right edge in Arabic). */
.perf-hamburger {
  display: none;
  margin-inline-start: 12px;
}
@media (max-width: 1023px) {
  .perf-hamburger {
    display: inline-flex;
  }
  /* Hide the static sidebar; the drawer takes over. k2-app-shell's
   * `data-empty-sidebar` collapse rule fires automatically when the
   * sidebar slot has no rendered child, so we hide via display:none on the
   * inner element rather than removing it from DOM (the latter would force
   * a full re-render on viewport-cross). */
  k2-app-sidebar.perf-sidebar {
    display: none;
  }
}
.perf-drawer-brand {
  padding: var(--k2-space-16, 16px);
  border-bottom: 1px solid var(--kcds-color-border-subtle, #e5e7eb);
}
.perf-drawer-nav {
  padding: var(--k2-space-12, 12px);
}
.perf-outlet {
  display: block;
  min-height: 0;
}

/* RTL — Arabic flips sidebar to the right edge naturally via writing-mode +
 * `border-inline-end`; nothing else needed here. */

/* ────────────────────────────────────────────────────────────────────────────
 * Generic page chrome shared by cluster pages.
 * Pages compose like:
 *   <k2-page>
 *     <header class="page-head"> <div>…title…</div> <div class="actions">…</div></header>
 *     <div class="toolbar">…</div>
 *     <section class="card">…</section>
 *   </k2-page>
 */
k2-page {
  display: block;
  /* K2 SDK defaults --k2-page-max-width to 1320px (js-kc-k2/src/k2ui.js
   * ~L21000), which leaves a wide empty gutter on 1920px+ monitors after
   * the 210px sidebar + 24px gap. KC Performance admin pages render
   * dense table data; let them use the full content region instead. */
  --k2-page-max-width: 100%;
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}
.page-head h1 {
  margin: 0 0 4px;
  /* PER-799 / KCDS admin H1: floor 24px (compact density), scale to 28px on
   * wider viewports. clamp() avoids a media-query without breaking compact. */
  font-size: clamp(24px, 2.2vw, 28px);
  font-weight: 700;
}
.page-head .muted {
  margin: 0;
  color: var(--kcds-color-text-secondary, #6b7280);
  font-size: 13px;
  max-width: 720px;
}
.page-head .actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

/* PER-810 — pageheader overflow menu. Save + Cancel stay as visible
 * k2-buttons; Preview / History / Delete collapse into a kebab dropdown
 * (KCDS Archetype 5 pageheader rule: ≤2 visible actions + overflow). */
.page-head .ph-kebab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--kcds-color-border-default, #e2e8f0);
  border-radius: 4px;
  color: var(--kcds-color-text-secondary, #4b5563);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition:
    background 120ms ease,
    color 120ms ease,
    border-color 120ms ease;
}
.page-head .ph-kebab:hover {
  background: var(--kcds-color-surface-canvas, rgba(79, 70, 229, 0.06));
  color: var(--kcds-color-text-primary, #1f2937);
  border-color: var(--kcds-color-primary, #4f46e5);
}
.page-head .ph-kebab:focus-visible {
  outline: 2px solid var(--kcds-color-primary, #4f46e5);
  outline-offset: 2px;
}
.page-head .ph-menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 8px 14px;
  background: transparent;
  border: 0;
  font: inherit;
  font-size: 14px;
  color: var(--kcds-color-text-primary, #1f2937);
  text-align: start;
  cursor: pointer;
}
.page-head .ph-menu-item:hover:not(:disabled) {
  background: var(--kcds-color-surface-canvas, rgba(79, 70, 229, 0.06));
}
.page-head .ph-menu-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.page-head .ph-menu-item.ph-menu-danger {
  color: var(--kcds-color-status-error, #b91c1c);
}
.page-head .ph-menu-item.ph-menu-danger:hover:not(:disabled) {
  background: var(--kcds-color-status-error-bg, rgba(220, 38, 38, 0.08));
}
.page-head .ph-menu-sep {
  height: 1px;
  margin: 4px 0;
  background: var(--kcds-color-border-default, #e2e8f0);
}

/* PER-816 — preview-modal skeleton. Animated shimmer reproduces a
 * section-heading + two body lines silhouette while the role-filtered
 * preview snapshot loads. Respects prefers-reduced-motion. */
.preview-skeleton {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 4px;
}
.skeleton-bar {
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--kcds-color-surface-subtle, #f1f5f9) 0%,
    var(--kcds-color-surface-canvas, #e2e8f0) 50%,
    var(--kcds-color-surface-subtle, #f1f5f9) 100%
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.4s ease-in-out infinite;
}
.skeleton-bar--h2 {
  height: 18px;
  width: 40%;
  margin-bottom: 4px;
}
.skeleton-bar--body {
  height: 12px;
  width: 100%;
}
.skeleton-bar--80 {
  width: 80%;
}
.skeleton-bar--60 {
  width: 60%;
}
@keyframes skeletonShimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton-bar {
    animation: none;
  }
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.toolbar k2-input {
  flex: 1;
  max-width: 400px;
}
.muted {
  color: var(--kcds-color-text-secondary, #6b7280);
}
.muted.small {
  font-size: 12px;
}
.center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 0;
}
.err {
  color: var(--kcds-color-status-error, #ef4444);
  font-size: 12px;
  margin: 4px 0 0;
}
.card {
  background: var(--kcds-color-surface-canvas, #fff);
  border: 1px solid var(--kcds-color-border-subtle, #e5e7eb);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
[data-kcds-theme='dark'] .card {
  background: var(--kcds-color-surface-elevated, #111827);
  border-color: var(--kcds-color-border-subtle, #1f2937);
}
/* Cap a single-column form body to a readable measure on wide viewports
   (redesign mockup .form-column). Stays inline-start aligned. */
.form-column {
  max-width: 720px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--kcds-color-text-secondary, #4b5563);
}

/* Native <input> / <select> / <textarea> inside .field — match k2-input look so
 * pages can mix native + K2 widgets without a visual jump. Bordered, padded,
 * KCDS-tokened, dark-mode aware. */
.field input[type='text'],
.field input[type='email'],
.field input[type='password'],
.field input[type='number'],
.field input[type='search'],
.field input[type='url'],
.field input[type='tel'],
.field select,
.field textarea {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--kcds-color-border-default, #d1d5db);
  /* PER-796 — native fields match the 4px shell radius (nav items, header
   * icon buttons, lang chip). k2-input wraps a shadow <input> whose pill
   * radius is owned by the SDK theme; the two coexist by design — the
   * shadow widget is visually distinct from a native field. */
  border-radius: 4px;
  background: var(--kcds-color-surface-canvas, #fff);
  color: var(--kcds-color-text-primary, #1f2937);
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--kcds-color-primary, #4f46e5);
  /* color-mix on the semantic primary token — no literal indigo fallback so
   * tenant theme overrides actually take effect on the focus ring. PER-796. */
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--kcds-color-primary, #4f46e5) 15%, transparent);
}
.field select {
  appearance: none;
  /* PER-796 — direction-aware chevron. background-position percentages are
   * NOT mirrored by direction, so we read inline-end via a logical-property
   * custom prop that flips under [dir="rtl"]. */
  --perf-select-chevron-x-1: calc(100% - 18px);
  --perf-select-chevron-x-2: calc(100% - 12px);
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    var(--perf-select-chevron-x-1) 50%,
    var(--perf-select-chevron-x-2) 50%;
  background-size:
    6px 6px,
    6px 6px;
  background-repeat: no-repeat;
  padding-inline-end: 32px;
  padding-inline-start: 12px;
  cursor: pointer;
}
[dir='rtl'] .field select {
  --perf-select-chevron-x-1: 18px;
  --perf-select-chevron-x-2: 12px;
}
[data-kcds-theme='dark'] .field input,
[data-kcds-theme='dark'] .field select,
[data-kcds-theme='dark'] .field textarea {
  background: var(--kcds-color-surface-elevated, #0f172a);
  color: var(--kcds-color-text-primary, #f1f5f9);
  border-color: var(--kcds-color-border-default, #1f2937);
}
.switch-row {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 720px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}
.sub-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.sub-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.sub-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

/* Table — generic. Cluster pages use class="k2-table". */
.k2-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}
.k2-table th,
.k2-table td {
  text-align: start;
  padding: 12px 16px;
  border-bottom: 1px solid var(--kcds-color-border-subtle, #e5e7eb);
  vertical-align: middle;
}
[data-kcds-theme='dark'] .k2-table th,
[data-kcds-theme='dark'] .k2-table td {
  border-color: var(--kcds-color-border-subtle, #1f2937);
}
.k2-table th {
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--kcds-color-text-tertiary, #6b7280);
  background: var(--kcds-color-surface-subtle, #f9fafb);
}
[data-kcds-theme='dark'] .k2-table th {
  background: var(--kcds-color-surface-subtle, #0f172a);
}
.k2-table tbody tr {
  cursor: default;
}
.k2-table tbody tr[data-row-id] {
  cursor: pointer;
}
.k2-table tbody tr[data-row-id]:hover {
  background: var(--kcds-color-surface-canvas, rgba(79, 70, 229, 0.04));
}
.k2-table .name {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Rating scale level chips on the list page. */
.levels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.level-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: var(--chip, #9ca3af);
}

/* ────────────────────────────────────────────────────────────────────────────
 * Modal / dialog — PER-797 retired the hand-rolled <dialog class="perf-modal">.
 * Cluster 2 modals now use <k2-dialog> from the K2 SDK, which ships chrome
 * (role, aria-modal, aria-labelledby, focus trap, ESC, backdrop click,
 * previous-focus restore, prefers-reduced-motion) out of the box. The only
 * piece that lives here is a width override so the rating-scale level row
 * (which hosts <k2-color-picker> inline — preview + hex + 12 swatches) fits
 * without truncating its label/description columns.
 */
k2-dialog#rs-modal {
  --k2-dialog-width: 960px;
}

/* Visually hidden — KCDS canonical is .sr-only (shipped by kcds.css:1526).
 * .visually-hidden is kept as a one-way alias while existing call sites
 * migrate (rating-scales-list-page.js still references it). New code MUST
 * use .sr-only. PER-799. */
.sr-only,
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Rating-scale level editor — a row of value / label / description / color /
 * remove. Wraps on narrow viewports. */
.levels-section {
  margin-top: 8px;
}
/* Color-ramp preview: each level's colour side by side (redesign mockup). */
.scale-preview {
  display: flex;
  height: 14px;
  border-radius: 9999px;
  overflow: hidden;
  margin: 8px 0 12px;
  border: 1px solid var(--kcds-color-border-subtle, #e5e7eb);
}
.scale-preview span {
  flex: 1;
}
.levels-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 8px;
}
.level-row {
  display: grid;
  /* PER-794 — `<k2-color-picker>` ships preview + hex input + swatches inline
   * (display:inline-flex), so the 5th column needs ~210px to host it without
   * vertical wrap. Old column was 60px (sized for raw <input type="color">). */
  grid-template-columns: 84px 1.4fr 1.6fr minmax(210px, auto) auto;
  gap: 10px;
  align-items: end;
}
.level-row .field {
  margin-bottom: 0;
}
.level-row .field.grow {
  min-width: 0;
}
.color-field {
  display: flex;
  align-items: center;
  gap: 6px;
}
/* PER-794 — k2-color-picker renders preview + hex input + swatches inline.
 * Let it claim its natural inline-block size; the parent .level-row grid is
 * sized to accommodate this (column 5 = minmax(210px, auto)). */
.color-field k2-color-picker {
  flex-shrink: 0;
}
.color-field input[type='color'] {
  appearance: none;
  -webkit-appearance: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--kcds-color-border-default, #d1d5db);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  padding: 0;
}
.color-field input[type='color']::-webkit-color-swatch-wrapper {
  padding: 4px;
}
.color-field input[type='color']::-webkit-color-swatch {
  border: 0;
  border-radius: 4px;
}
.color-field .clear-color {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--kcds-color-text-tertiary, #6b7280);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  width: 22px;
  height: 22px;
  border-radius: 50%;
}
.color-field .clear-color:hover {
  background: var(--kcds-color-surface-canvas, rgba(0, 0, 0, 0.06));
  color: var(--kcds-color-text-primary, #1f2937);
}
.row-remove {
  display: flex;
  align-items: center;
}
@media (max-width: 720px) {
  .level-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* Row actions column in tables (k2-table). */
.k2-table .row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* Banner / alert variants inside cards (info/warn for "in use by N cycles"). */
.in-use-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 4px;
  /* PER-796 — semantic token (was raw rgba literal). color-mix keeps the
   * banner tied to whichever brand token is in effect (tenant theming). */
  background: color-mix(in srgb, var(--kcds-color-primary, #4f46e5) 8%, transparent);
  color: var(--kcds-color-primary, #4f46e5);
  font-size: 13px;
  margin-bottom: 16px;
}
.in-use-banner strong {
  font-weight: 600;
}

/* Section / question card framing inside the template editor. Each section
 * gets a soft card to visually group its child question list. */
.section-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.section {
  border: 1px solid var(--kcds-color-border-subtle, #e5e7eb);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--kcds-color-surface-subtle, #f9fafb);
}
[data-kcds-theme='dark'] .section {
  border-color: var(--kcds-color-border-subtle, #1f2937);
  background: var(--kcds-color-surface-subtle, #0f172a);
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.section-head .move-buttons {
  display: inline-flex;
  gap: 4px;
}
.question-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.question {
  border: 1px dashed var(--kcds-color-border-default, #d1d5db);
  border-radius: 10px;
  padding: 12px;
  background: var(--kcds-color-surface-canvas, #fff);
}
[data-kcds-theme='dark'] .question {
  background: var(--kcds-color-surface-elevated, #111827);
  border-color: var(--kcds-color-border-default, #1f2937);
}
.question-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.sub-head.sub-head--inline {
  margin-top: 6px;
  margin-bottom: 6px;
}

/* Drag handle on draggable rows. Cursor + a colour change on :active so the
 * user feels the affordance. Real DnD is via the HTML5 drag API on the row. */
.drag-handle {
  cursor: grab;
  color: var(--kcds-color-text-tertiary, #9ca3af);
  user-select: none;
  padding: 0 6px;
  font-size: 14px;
  line-height: 1;
}
.drag-handle:active {
  cursor: grabbing;
  color: var(--kcds-color-primary, #4f46e5);
}
li[draggable='true'].drag-over {
  outline: 2px dashed var(--kcds-color-primary, #4f46e5);
  outline-offset: -4px;
}
li[draggable='true'].dragging {
  opacity: 0.5;
}

/* Visibility-rule inline editor under a section/question. */
.vis-rule {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--kcds-color-border-subtle, #e5e7eb);
  border-radius: 8px;
  background: var(--kcds-color-surface-canvas, #fff);
  margin-top: 8px;
}
[data-kcds-theme='dark'] .vis-rule {
  background: var(--kcds-color-surface-elevated, #0f172a);
  border-color: var(--kcds-color-border-subtle, #1f2937);
}
.vis-rule-head {
  font-size: 12px;
  font-weight: 600;
  color: var(--kcds-color-text-secondary, #4b5563);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Preview surface — read-only rendering of a template under role-filter. */
.preview-section {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--kcds-color-border-subtle, #e5e7eb);
}
.preview-section:last-child {
  border-bottom: 0;
}
.preview-section h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}
.preview-question {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--kcds-color-surface-subtle, #f9fafb);
}
[data-kcds-theme='dark'] .preview-question {
  background: var(--kcds-color-surface-subtle, #0f172a);
}
.preview-question .q-text {
  font-weight: 600;
  margin: 0 0 4px;
}
.preview-question .q-meta {
  font-size: 11px;
  color: var(--kcds-color-text-tertiary, #6b7280);
  display: inline-flex;
  gap: 6px;
}

/* Version history drawer list items. */
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* PER-807 — current live version banner. History entries store pre-change
 * versions only, so the live one needs its own surface above the list. */
.history-current {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--kcds-color-primary, #4f46e5) 8%, transparent);
  color: var(--kcds-color-primary, #4f46e5);
  font-weight: 600;
  font-size: 13px;
}
.history-row {
  border: 1px solid var(--kcds-color-border-subtle, #e5e7eb);
  border-radius: 10px;
  padding: 12px;
  background: var(--kcds-color-surface-canvas, #fff);
}
[data-kcds-theme='dark'] .history-row {
  background: var(--kcds-color-surface-elevated, #111827);
  border-color: var(--kcds-color-border-subtle, #1f2937);
}
.history-row .row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}
.history-row .row-meta {
  font-size: 12px;
  color: var(--kcds-color-text-secondary, #6b7280);
}
.history-row .row-actions {
  display: inline-flex;
  gap: 6px;
  margin-top: 6px;
}

/* Tab strip for preview as employee / manager. */
.tabstrip {
  display: inline-flex;
  border: 1px solid var(--kcds-color-border-default, #d1d5db);
  border-radius: 8px;
  padding: 2px;
  margin-bottom: 14px;
}
.tabstrip button {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--kcds-color-text-secondary, #4b5563);
}
.tabstrip button.active {
  background: var(--kcds-color-primary, #4f46e5);
  color: var(--kcds-color-on-primary, #fff);
}

/* Translations inline editor block. */
.translations-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.translations-block summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--kcds-color-primary, #4f46e5);
}
.translations-block .grid {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 6px 10px;
  margin-top: 6px;
}

/* PER-805 — let level-row grid items shrink below their content min-width
 * so the row never forces horizontal scroll inside the rating-scale modal.
 * Pairs with `style="--width: 720px"` on the dialog host. */
.level-row .field {
  min-width: 0;
}

/* PER-808 — Sign-in card. Native inline styles replaced by named classes
 * so the K2-ported login surface picks up density tokens like the rest of
 * the app. .auth-form stacks <k2-input> + <k2-button> with consistent
 * vertical rhythm. The card itself is centered by `.perf-outlet-host
 * --centered` (PER-795); .auth-card just sets the column layout + width
 * cap. No vertical margin — that previously pushed the outlet a few
 * pixels past the viewport and made the browser allocate an empty
 * scrollbar gutter (fixed alongside the box-sizing rule on the centered
 * outlet host above). */
.auth-card {
  width: min(420px, 100%);
  margin-inline: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.auth-card h1 {
  margin: 0 0 4px;
}
.auth-card .muted {
  margin: 0 0 16px;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}
.auth-form k2-button {
  margin-top: 8px;
  align-self: stretch;
}

/* PER-819 — clickable goal rows on /my-goals open the editor. Pair
 * `cursor: pointer` + hover tint so the row affordance reads as
 * interactive (KCDS data-table convention; our `<table class="k2-table">`
 * does not get cursor styling from the SDK out of the box because we are
 * not yet on `<k2-data-table>` here). Focus ring for keyboard parity. */
tr.goals-row {
  cursor: pointer;
  transition: background 120ms ease;
}
tr.goals-row:hover {
  background: var(--kcds-color-surface-canvas, rgba(79, 70, 229, 0.06));
}
tr.goals-row:focus-visible {
  outline: 2px solid var(--kcds-color-primary, #4f46e5);
  outline-offset: -2px;
}

/* PER-819 detail page — read-only goal detail surface. Mirrors the
 * card / muted / page-head utilities; adds list + pill + progress styles. */
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.card .kv {
  display: grid;
  grid-template-columns: minmax(140px, max-content) 1fr;
  column-gap: 16px;
  row-gap: 8px;
  margin: 0;
}
.card .kv dt {
  font-weight: 600;
  color: var(--im-text-secondary, #4b5563);
}
.card .kv dd {
  margin: 0;
  color: var(--im-text, inherit);
}
.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--im-border, #e5e7eb);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--k2-color-primary, var(--im-primary, #4f46e5));
  transition: width 200ms ease;
}
.progress-pct {
  font-weight: 600;
  min-width: 48px;
  text-align: end;
}
.small-heading {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 12px 0 6px;
}
.confidence-list,
.notes-timeline,
.attachment-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}
.confidence-list li,
.notes-timeline li {
  padding: 8px 0;
  border-bottom: 1px solid var(--im-border, #e5e7eb);
}
.confidence-list li:last-child,
.notes-timeline li:last-child {
  border-bottom: 0;
}
.conf-value {
  display: inline-block;
  min-width: 48px;
  font-weight: 600;
  margin-inline-end: 8px;
}
.conf-note,
.note-text {
  margin: 4px 0 0;
  white-space: pre-wrap;
}
.note-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
}
.attachment-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}
.att-icon {
  flex: 0 0 auto;
}
.att-name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* PER-819 confidence-cadence mutators on detail page. */
.conf-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.conf-head h2 {
  margin: 0;
}
.field.inline {
  display: flex;
  align-items: center;
  gap: 8px;
}
.field.inline label {
  margin: 0;
}
.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
}
.slider-row input[type='range'] {
  flex: 1;
  accent-color: var(--k2-color-primary, var(--im-primary, #4f46e5));
}
.slider-row .conf-value {
  min-width: 48px;
  text-align: end;
}
.conf-submit-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* PER-819 notes + attachment mutators on the goal detail page. */
.note-submit-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}
.upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.attachment-list li {
  gap: 12px;
}
.attachment-list li k2-button {
  flex: 0 0 auto;
  margin-inline-start: auto;
}
