/* Performance-only finishing layer. Reuse HR tokens; do not restyle other
   HR views or couple presentation to score / confirmation state. */
body.performance-workspace-v1 {
  --bg: var(--hr-ui-canvas);
  --bg-2: var(--hr-ui-surface);
  --ink: var(--hr-ui-ink);
  --muted: var(--hr-ui-muted);
  --faint: var(--hr-ui-muted);
  --line: var(--hr-ui-line);
  --blue: var(--hr-ui-blue);
  --blue-2: var(--hr-ui-blue);
  --cyan: var(--hr-ui-blue);
  --radius-xl: var(--hr-ui-radius);
  --radius-lg: var(--hr-ui-radius);
  --shadow: var(--hr-ui-shadow);
  --shadow-soft: var(--hr-ui-shadow);
  background: var(--hr-ui-canvas);
  color: var(--hr-ui-ink);
}

body.performance-workspace-v1 :is(.panel, .department-card, .detail-panel,
  .toolbar, .metric-card, .hero-panel, .score-modal, .rule-editor-card) {
  border-color: var(--hr-ui-line);
  border-radius: var(--hr-ui-radius);
  background: var(--hr-ui-surface);
  box-shadow: var(--hr-ui-shadow);
}
body.performance-workspace-v1 .topbar {
  border-radius: 0;
  border-bottom: 1px solid var(--hr-ui-line);
  background: var(--hr-ui-canvas);
  box-shadow: none;
}
body.performance-workspace-v1 .topbar h1 { line-height: 1.35; }
body.performance-workspace-v1 .topbar .kicker { color: var(--hr-ui-muted); }
body.performance-workspace-v1 .logo,
body.performance-workspace-v1 .performance-brand-mark {
  background: linear-gradient(145deg, #32343a, #191b20);
  box-shadow: none;
  color: #fff;
}
body.performance-workspace-v1 .sidebar { padding: 18px 12px 14px; }
body.performance-workspace-v1 .sidebar::before { content: none; }
body.performance-workspace-v1 .performance-sidebar-brand {
  display: flex;
  gap: 11px;
  align-items: center;
  min-height: 54px;
  margin: 0 4px 20px;
  color: var(--hr-ui-ink);
  text-decoration: none;
}
body.performance-workspace-v1 .performance-brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  height: 42px;
  border-radius: 13px;
  font-size: 15px;
  font-weight: 700;
}
body.performance-workspace-v1 .performance-sidebar-brand strong {
  display: block;
  font-size: 15px;
  font-weight: 650;
}
body.performance-workspace-v1 .performance-sidebar-brand small {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--hr-ui-muted);
}
body.performance-workspace-v1 .side-note {
  color: var(--hr-ui-muted);
  background: var(--hr-ui-surface);
  border: 1px solid var(--hr-ui-line);
}
body.performance-workspace-v1 .side-note::after { content: none; }
body.performance-workspace-v1 .side-note strong {
  color: var(--hr-ui-ink);
  font-size: 13px;
  font-weight: 650;
}
body.performance-workspace-v1 .side-note span { color: var(--hr-ui-muted); }

body.performance-workspace-v1 .btn {
  border-radius: 12px;
  font-weight: 600;
  box-shadow: none;
  transition: background-color .15s, border-color .15s;
}
body.performance-workspace-v1 .btn:hover { transform: none; box-shadow: none; }
body.performance-workspace-v1 .btn.primary {
  background: var(--hr-ui-blue);
  border: 1px solid var(--hr-ui-blue);
}
body.performance-workspace-v1 .btn.soft {
  background: var(--hr-ui-blue-soft);
  color: var(--hr-ui-blue);
  border-color: transparent;
}
body.performance-workspace-v1 :is(.btn.ghost, .btn.back-home) {
  background: var(--hr-ui-surface);
  color: var(--hr-ui-ink);
  border-color: var(--hr-ui-line);
}
body.performance-workspace-v1 .metric-card::before { content: none; }
body.performance-workspace-v1 :is(.metric-card .title, .metric-card .sub) {
  font-weight: 500;
  line-height: 1.55;
}
body.performance-workspace-v1 .metric-card .num { font-weight: 700; }
body.performance-workspace-v1 :is(.metric-card, .rule-card, .department-card,
  .employee-section, .history-dept-card):hover {
  transform: none;
  box-shadow: var(--hr-ui-shadow);
}
body.performance-workspace-v1 :is(.section-title h2, .dept-title h3, .rule-card h3) {
  color: var(--hr-ui-ink);
  font-size: 19px;
  line-height: 1.4;
  font-weight: 650;
}
body.performance-workspace-v1 :is(.section-title p, .dept-title p, .hero-panel p) {
  font-weight: 500;
  line-height: 1.6;
}
body.performance-workspace-v1 :is(.field, .search, .filter-grid input,
  .filter-grid select, .rule-editor-head input, .rule-editor-head select,
  .module-editor-row input, .module-editor-row select) {
  background: var(--hr-ui-surface);
  border-color: var(--hr-ui-line);
  border-radius: 12px;
  color: var(--hr-ui-ink);
  box-shadow: none;
}
body.performance-workspace-v1 .segmented {
  background: var(--hr-ui-canvas);
  gap: 4px;
}
body.performance-workspace-v1 .segmented button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--hr-ui-muted);
  font-weight: 600;
  box-shadow: none;
}
body.performance-workspace-v1 .segmented button.active,
body.performance-workspace-v1 .segmented button:hover {
  background: var(--hr-ui-surface);
  color: var(--hr-ui-blue);
  border-color: var(--hr-ui-line);
  box-shadow: none;
}
body.performance-workspace-v1 .dept-head { background: var(--hr-ui-surface); }
body.performance-workspace-v1 .dept-icon {
  background: var(--hr-ui-blue-soft);
  color: var(--hr-ui-blue);
  box-shadow: none;
}
body.performance-workspace-v1 :is(.performance-card .table-wrap, thead th,
  .history-table thead th, .breakdown-head) {
  background: var(--hr-ui-canvas);
  color: var(--hr-ui-muted);
}
body.performance-workspace-v1 :is(tbody td, .performance-card table,
  .break-row, .rule-editor-head, .module-editor-row, .score-modal-foot) {
  border-color: var(--hr-ui-line);
}
body.performance-workspace-v1 tbody tr:hover td { background: var(--hr-ui-canvas); }
body.performance-workspace-v1 tbody tr.selected td { background: var(--hr-ui-blue-soft); }
body.performance-workspace-v1 :is(.scoreline, .stat-chip) { color: var(--hr-ui-ink); }
body.performance-workspace-v1 :is(.mini-bar, .progress-track) { background: var(--hr-ui-line); }
body.performance-workspace-v1 :is(.mini-bar span, .progress-fill, .step .index) {
  background: var(--hr-ui-blue);
  box-shadow: none;
}
body.performance-workspace-v1 :is(.rule-card, .progress-box, .upload-box,
  .action-card, .step, .score-info-card, .score-edit-item, .score-issue-item,
  .notify-summary, .notify-field textarea, .score-modal-head, .score-modal-foot,
  .score-main-card, .score-issue-card, .score-editor-card, .score-sub-card,
  .score-info-item, .rule-editor-body) {
  background: var(--hr-ui-surface);
  border-color: var(--hr-ui-line);
  box-shadow: none;
}
body.performance-workspace-v1 :is(.rule-card .badge, .pill, .module-tags span,
  .score-total-box, .score-issue-index, .avatar) {
  color: var(--hr-ui-blue);
  background: var(--hr-ui-blue-soft);
  border-color: transparent;
  box-shadow: none;
}
body.performance-workspace-v1 .rule-card:hover { transform: none; }
body.performance-workspace-v1 .score-card-head {
  background: var(--hr-ui-canvas);
  border-color: var(--hr-ui-line);
}
body.performance-workspace-v1 .score-main-card > .score-card-head,
body.performance-workspace-v1 .score-issue-card > .score-card-head {
  background: var(--hr-ui-canvas);
}
body.performance-workspace-v1 .score-modal {
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}
body.performance-workspace-v1 :is(.score-modal-body, .notify-modal-body) {
  min-height: 0;
  overflow-y: auto;
}
body.performance-workspace-v1 .score-issue-list {
  max-height: none;
  overflow: visible;
}

/* The flex child's min-height must be zero: otherwise long module / issue
   content grows past the viewport and the outer overflow clips its end. */
body.performance-workspace-v1 .content:not(.detail-hidden) {
  grid-template-columns: minmax(0, 1fr) clamp(300px, 25vw, 360px);
  gap: 16px;
}
body.performance-workspace-v1 .detail-panel {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: calc(var(--performance-header-height, 88px) + 16px);
  display: flex;
  flex-direction: column;
  align-self: start;
  min-width: 0;
  min-height: 0;
  max-height: calc(100vh - var(--performance-preview-top, 104px) - 16px);
  max-height: calc(100dvh - var(--performance-preview-top, 104px) - 16px);
  overflow: hidden;
}
body.performance-workspace-v1 .detail-hero {
  flex: 0 0 auto;
  padding: 18px;
  border-bottom: 1px solid var(--hr-ui-line);
  background: var(--hr-ui-surface);
  color: var(--hr-ui-ink);
}
body.performance-workspace-v1 .detail-hero::after { content: none; }
body.performance-workspace-v1 .detail-hero .small {
  color: var(--hr-ui-muted);
  font-size: 10px;
  letter-spacing: .05em;
}
body.performance-workspace-v1 .detail-hero h2 {
  margin-top: 6px;
  font-size: 22px;
  line-height: 1.4;
  font-weight: 650;
}
body.performance-workspace-v1 .detail-hero p {
  color: var(--hr-ui-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
body.performance-workspace-v1 .detail-body {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: block;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  scroll-behavior: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}
body.performance-workspace-v1 .detail-body > * + * { margin-top: 16px; }
body.performance-workspace-v1 .detail-body:focus-visible {
  outline: 2px solid var(--hr-ui-blue);
  outline-offset: -3px;
}
body.performance-workspace-v1 .detail-kpi {
  min-width: 0;
  background: var(--hr-ui-canvas);
  border-color: var(--hr-ui-line);
  text-align: center;
}
body.performance-workspace-v1 .detail-kpi:last-child { grid-column: 1 / -1; }
body.performance-workspace-v1 .detail-kpi span { font-weight: 500; }
body.performance-workspace-v1 .detail-kpi strong {
  font-size: 20px;
  font-weight: 650;
  line-height: 1.5;
}
body.performance-workspace-v1 .breakdown-head {
  align-items: start;
  flex-wrap: wrap;
  gap: 6px;
  font-weight: 600;
}
body.performance-workspace-v1 .breakdown-head small { overflow-wrap: anywhere; }
body.performance-workspace-v1 .break-meta {
  flex-wrap: wrap;
  gap: 4px 8px;
  line-height: 1.6;
  font-size: 13px;
  font-weight: 600;
}
body.performance-workspace-v1 .break-meta small { font-weight: 500; }
body.performance-workspace-v1 .audit-item {
  border-color: var(--hr-ui-line);
  align-items: start;
  grid-template-columns: 26px minmax(0, 1fr);
  padding: 12px;
}
body.performance-workspace-v1 .audit-item .dot {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  color: var(--hr-ui-blue);
  background: var(--hr-ui-blue-soft);
}
body.performance-workspace-v1 .audit-item strong { font-weight: 600; }
body.performance-workspace-v1 .audit-item span {
  font-size: 13px;
  line-height: 1.65;
  font-weight: 400;
  color: var(--hr-ui-muted);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
body.performance-workspace-v1 .detail-end {
  color: var(--hr-ui-muted);
  font-size: 11px;
  line-height: 1.5;
  padding-top: 12px;
  border-top: 1px solid var(--hr-ui-line);
  text-align: center;
}

/* Keep the preview at the right on desktop, even in a narrower app window.
   Only the results table may scroll horizontally; the page itself must fit. */
@media (min-width: 921px) {
  body.performance-workspace-v1 .performance-card .table-wrap {
    overflow-x: auto;
    padding: 0 12px 12px;
  }
  body.performance-workspace-v1 .performance-card table { min-width: 920px; }
}
@media (max-width: 920px) {
  body.performance-workspace-v1 .content { grid-template-columns: minmax(0, 1fr); }
  body.performance-workspace-v1 .detail-panel {
    grid-column: 1;
    grid-row: auto;
    position: static;
    max-height: none;
  }
  body.performance-workspace-v1 .detail-body {
    overflow: visible;
    scrollbar-gutter: auto;
  }
}
@media (max-height: 560px) {
  body.performance-workspace-v1 .detail-panel {
    position: static;
    max-height: none;
  }
  body.performance-workspace-v1 .detail-body {
    overflow: visible;
    scrollbar-gutter: auto;
  }
}
@media (max-width: 980px) {
  body.performance-workspace-v1 .topbar { position: static; }
}
@media (max-width: 760px) {
  body.performance-workspace-v1 tbody tr {
    background: var(--hr-ui-surface);
    border-color: var(--hr-ui-line);
    border-radius: 14px;
    box-shadow: none;
  }
  body.performance-workspace-v1 :is(tbody tr:hover td, tbody tr.selected td) {
    background: transparent;
  }
  body.performance-workspace-v1 tbody tr.selected { border-color: var(--hr-ui-blue); }
}
