/* Scoped operational views for /admin. Grouped and flat views share the same
   table DOM; all visual rules stay scoped. */
.cpg-ops {
  --ops-bg: var(--panel);
  --ops-surface: var(--panel2);
  --ops-line: var(--line);
  --ops-text: var(--ink);
  --ops-text-soft: var(--ink2);
  --ops-text-muted: var(--ink3);
  --ops-text-faint: var(--ink4);
  --ops-accent: var(--purple-l);
  --ops-accent-deep: var(--purple);
  --ops-danger: var(--red, var(--danger));
  --ops-warning: var(--amber);
  --ops-positive: var(--green);
  position: relative;
  color: var(--ops-text);
  font-family: var(--sans);
}

.cpg-ops *, .cpg-ops *::before, .cpg-ops *::after { box-sizing: border-box; }
.cpg-ops button, .cpg-ops input, .cpg-ops select { font: inherit; }
.cpg-ops button, .cpg-ops select { cursor: pointer; }
.cpg-ops button:disabled, .cpg-ops select:disabled { cursor: not-allowed; opacity: .46; }
.cpg-ops button:focus-visible, .cpg-ops input:focus-visible, .cpg-ops select:focus-visible,
.cpg-ops [tabindex]:focus-visible, .cpg-ops summary:focus-visible {
  outline: 2px solid var(--ops-accent);
  outline-offset: 2px;
}

.cpg-ops-sr {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.cpg-ops-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin: 0 0 16px;
}
.cpg-ops-kicker {
  margin: 0 0 6px;
  color: var(--ops-accent);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.cpg-ops-head h2 { margin: 0; font-size: 25px; line-height: 1.1; letter-spacing: -.02em; }
.cpg-ops-lede { max-width: 72ch; margin: 7px 0 0; color: var(--ops-text-muted); font-size: 13px; line-height: 1.55; }
.cpg-ops-count {
  flex: none;
  color: var(--ops-text-faint);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.cpg-ops-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 10px;
  background: var(--ops-bg);
  border: 1px solid var(--ops-line);
  border-radius: 12px;
}
.cpg-ops-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 260px;
  min-width: 220px;
}
.cpg-ops-search svg { position: absolute; left: 11px; color: var(--ops-text-faint); pointer-events: none; }
.cpg-ops-search input,
.cpg-ops-field input,
.cpg-ops-field select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--ops-line);
  border-radius: 8px;
  color: var(--ops-text);
  background: transparent;
}
.cpg-ops-search input { padding: 0 12px 0 34px; }
.cpg-ops-field input, .cpg-ops-field select { padding: 0 28px 0 10px; }
.cpg-ops-search input::placeholder, .cpg-ops-field input::placeholder { color: var(--ops-text-faint); }
.cpg-ops-field { display: flex; flex-direction: column; gap: 5px; flex: 0 1 150px; min-width: 112px; }
.cpg-ops-field > span {
  padding-left: 2px;
  color: var(--ops-text-faint);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.cpg-ops-btn,
.cpg-ops-view button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid var(--ops-line);
  border-radius: 8px;
  color: var(--ops-text-soft);
  background: color-mix(in srgb, var(--ops-text) 5%, transparent);
  font-size: 12px;
  font-weight: 700;
}
.cpg-ops-btn:hover, .cpg-ops-view button:hover { color: var(--ops-text); background: color-mix(in srgb, var(--ops-text) 10%, transparent); }
.cpg-ops-btn-icon { width: 36px; padding: 0; flex: none; }
.cpg-ops-btn-danger:hover { color: var(--ops-danger); border-color: color-mix(in srgb, var(--ops-danger) 45%, transparent); background: color-mix(in srgb, var(--ops-danger) 12%, transparent); }
.cpg-ops-view { display: flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--ops-line); border-radius: 11px; background: color-mix(in srgb, var(--ops-bg) 88%, #000); }
.cpg-ops-view button { min-height: 30px; border: 2px solid transparent; border-radius: 8px; background: transparent; }
.cpg-ops-view button.is-on, .cpg-ops-view button[aria-pressed="true"] { color: var(--ops-text); border-color: var(--ops-accent-deep); background: color-mix(in srgb, var(--ops-accent-deep) 20%, var(--ops-bg)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ops-accent) 35%, transparent); }

.cpg-ops-content { min-height: 260px; }
.cpg-ops-loading, .cpg-ops-empty {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  padding: 30px;
  color: var(--ops-text-faint);
  text-align: center;
}
.cpg-ops-empty strong { color: var(--ops-text-soft); font-size: 14px; }
.cpg-ops-empty span { font-size: 12px; }
.cpg-ops-empty-error strong, .cpg-ops-empty-error span { color: var(--ops-danger); }

/* Henshu flat List structure: group-view > table > shell > sticky header/rows. */
.cpg-ops .group-view.group-view-flat {
  width: 100%;
  min-height: 260px;
  margin: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #0e0e10;
  border: 1px solid var(--ops-line);
  border-radius: 14px;
}
.cpg-ops .group-view-grouped .group-view.group-view-flat { min-height: 0; border: 0; border-radius: 0; }
.cpg-ops .group-view-grouped .group-view.group-view-flat .cpg-ops-empty { min-height: 64px; padding: 14px; }
.cpg-ops .gv-flat-table { flex: 1; min-height: 0; overflow: auto; }
.cpg-ops .gv-flat-shell { display: flex; flex-direction: column; width: 100%; min-width: min-content; }
.cpg-ops .gv-flat-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  min-width: min-content;
  background: #0e0e10;
  border-bottom: 1px solid var(--ops-line);
}
.cpg-ops .gv-flat-col {
  min-width: 0;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 0 15px;
  border: 0;
  border-right: 0;
  color: var(--ops-text-faint);
  background: transparent;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .09em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.cpg-ops button.gv-flat-col:hover, .cpg-ops .gv-flat-col.is-sorted { color: var(--ops-accent); background: color-mix(in srgb, var(--ops-accent) 6%, transparent); }
.cpg-ops .gv-flat-col.is-sorted svg { transform: rotate(180deg); }
.cpg-ops .gv-flat-col[aria-sort="ascending"] svg { transform: none; }
.cpg-ops .gv-flat-col:last-child { border-right: 0; }
.cpg-ops .gv-flat-row {
  display: grid;
  min-width: min-content;
  min-height: 66px;
  align-items: stretch;
  border-bottom: 1px solid var(--ops-line);
  color: var(--ops-text-soft);
  transition: background var(--dur-quick, .15s) ease;
}
.cpg-ops .gv-flat-row:last-child { border-bottom: 0; }
.cpg-ops .gv-flat-row:hover { background: color-mix(in srgb, var(--ops-text) 3%, transparent); }
.cpg-ops .gv-flat-row.is-archived { opacity: .62; }
.cpg-ops .gv-flat-row.is-important, .cpg-ops .gv-flat-row.is-favorite { box-shadow: inset 3px 0 0 var(--ops-accent); }
.cpg-ops .gv-flat-cell {
  min-width: 0;
  min-height: 66px;
  display: flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  padding: 11px 15px;
  border-right: 0;
  color: var(--ops-text-soft);
  font-size: 12px;
}
.cpg-ops .gv-flat-cell:last-child { border-right: 0; }
.cpg-ops .gv-flat-cell > span, .cpg-ops .gv-flat-cell > time { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cpg-ops .gv-flat-cell-title { align-items: flex-start; justify-content: center; flex-direction: column; }
.cpg-ops .gv-flat-cell-title strong { max-width: 100%; overflow: hidden; color: var(--ops-text); font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.cpg-ops .gv-flat-cell-title small { max-width: 100%; overflow: hidden; color: var(--ops-text-faint); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.cpg-ops .gv-flat-cell-mark { justify-content: center; }
.cpg-ops .gv-flat-cell-actions { justify-content: flex-end; gap: 4px; }
.cpg-ops .gv-flat-cell-actions .cpg-ops-btn { width: 30px; min-height: 30px; }
.cpg-ops-feedback .gv-flat-header, .cpg-ops-feedback .gv-flat-row { grid-template-columns: 82px minmax(250px, 1.7fr) minmax(150px, .9fr) 120px minmax(170px, 1fr) 116px minmax(160px, .9fr) 116px; }
.cpg-ops-bugs .group-view .gv-flat-header, .cpg-ops-bugs .group-view .gv-flat-row { grid-template-columns: 78px minmax(260px, 1.8fr) 138px 138px minmax(155px, .9fr) 116px 116px; }

.cpg-ops-mark {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  color: var(--ops-text-faint);
  background: transparent;
}
.cpg-ops-mark:hover { color: var(--ops-accent); background: color-mix(in srgb, var(--ops-accent) 10%, transparent); }
.cpg-ops-mark.is-on { color: var(--ops-accent); }
.cpg-ops-favorite.is-on svg { fill: currentColor; }
.cpg-ops-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  max-width: 100%;
  padding: 2px 8px;
  overflow: hidden;
  border-radius: 999px;
  color: var(--ops-text-muted);
  background: color-mix(in srgb, var(--ops-text) 7%, transparent);
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cpg-ops-inline-select {
  max-width: 100%;
  min-height: 28px;
  padding: 0 22px 0 7px;
  border: 1px solid var(--ops-line);
  border-radius: 7px;
  color: var(--ops-text-soft);
  background: var(--ops-surface);
  font-size: 11px;
  font-weight: 700;
}
.cpg-ops .priority-select { color: var(--ops-text); }
.cpg-ops .priority-p0 { box-shadow: inset 3px 0 0 var(--ops-danger); }
.cpg-ops .priority-p1 { box-shadow: inset 3px 0 0 var(--ops-warning); }
.cpg-ops .priority-p2 { box-shadow: inset 3px 0 0 var(--ops-accent); }

.cpg-ops-undo, .cpg-ops-isolation {
  position: sticky;
  bottom: 16px;
  z-index: 8;
  width: max-content;
  max-width: calc(100% - 24px);
  margin: 12px auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 9px 10px 9px 14px;
  border: 1px solid var(--ops-line);
  border-radius: 10px;
  color: var(--ops-text);
  background: var(--ops-surface);
  font-size: 12px;
}
.cpg-ops-undo[hidden], .cpg-ops-isolation[hidden] { display: none; }
.cpg-ops-isolation { position: static; width: 100%; max-width: none; margin: 0 0 12px; border-color: color-mix(in srgb, var(--ops-accent) 42%, var(--ops-line)); }
.cpg-ops-isolation > span { min-width: 0; display: flex; align-items: center; gap: 8px; }
.cpg-ops-isolation code { min-width: 0; overflow: hidden; color: var(--ops-accent); font-family: var(--mono); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.cpg-ops-dialog {
  width: min(680px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 0;
  overflow: auto;
  border: 1px solid var(--ops-line);
  border-radius: 14px;
  color: var(--ops-text);
  background: var(--ops-bg);
}
.cpg-ops-dialog::backdrop { background: color-mix(in srgb, var(--bg) 72%, transparent); }
.cpg-ops-dialog-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 18px; border-bottom: 1px solid var(--ops-line); background: var(--ops-bg); }
.cpg-ops-dialog-head p { margin: 0 0 5px; color: var(--ops-accent); font-family: var(--mono); font-size: 9px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.cpg-ops-dialog-head h3 { margin: 0; font-size: 20px; line-height: 1.3; }
.cpg-ops-dialog-copy { margin: 0; padding: 18px; border-bottom: 1px solid var(--ops-line); color: var(--ops-text-soft); font-size: 14px; line-height: 1.65; white-space: pre-wrap; }
.cpg-ops-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0; padding: 1px; background: var(--ops-line); }
.cpg-ops-detail-grid > div { min-width: 0; padding: 13px 16px; background: var(--ops-bg); }
.cpg-ops-detail-grid dt { margin-bottom: 5px; color: var(--ops-text-faint); font-family: var(--mono); font-size: 9px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.cpg-ops-detail-grid dd { margin: 0; overflow-wrap: anywhere; color: var(--ops-text-soft); font-size: 12px; }
.cpg-ops-narrative { padding: 4px 18px 0; }
.cpg-ops-narrative section { padding: 14px 0; border-bottom: 1px solid var(--ops-line); }
.cpg-ops-narrative h4 { margin: 0 0 6px; color: var(--ops-text-faint); font-family: var(--mono); font-size: 9px; letter-spacing: .09em; text-transform: uppercase; }
.cpg-ops-narrative p { margin: 0; color: var(--ops-text-soft); font-size: 13px; line-height: 1.6; white-space: pre-wrap; }
.cpg-ops-raw { padding: 14px 18px 18px; }
.cpg-ops-raw summary { color: var(--ops-text-muted); cursor: pointer; font-size: 12px; font-weight: 700; }
.cpg-ops pre { max-width: 100%; margin: 12px 0 0; overflow: auto; color: var(--ops-text-muted); font: 11px/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }

.cpg-ops-live {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 14px;
  border: 1px solid var(--ops-line);
  border-radius: 9px;
  color: var(--ops-text);
  background: var(--ops-surface);
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity var(--dur-quick, .15s) ease, transform var(--dur-quick, .15s) ease;
}
.cpg-ops-live.is-visible { opacity: 1; transform: translate(-50%, 0); }
.cpg-ops-live.is-error { color: var(--ops-danger); border-color: color-mix(in srgb, var(--ops-danger) 45%, transparent); }

/* Server console */
.cpg-ops-console .cpg-ops-toolbar { align-items: flex-end; }
.cpg-console-status { min-height: 32px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 12px; border: 1px solid var(--ops-line); border-bottom: 0; border-radius: 10px 10px 0 0; color: var(--ops-text-faint); background: var(--ops-bg); font: 10px var(--mono); }
.cpg-console-status .is-error { color: var(--ops-danger); }
.cpg-console-stream { max-height: min(720px, 72vh); min-height: 300px; overflow: auto; border: 1px solid var(--ops-line); background: var(--ops-bg); }
.cpg-console-line { padding: 11px 12px; border-bottom: 1px solid var(--ops-line); color: var(--ops-text-soft); font-family: var(--mono); font-size: 11px; line-height: 1.45; }
.cpg-console-line:last-child { border-bottom: 0; }
.cpg-console-line:hover { background: color-mix(in srgb, var(--ops-text) 3%, transparent); }
.cpg-console-main { display: grid; grid-template-columns: 170px 58px minmax(90px, 130px) minmax(220px, 1fr) auto; align-items: center; gap: 10px; }
.cpg-console-main time { color: var(--ops-text-faint); font-variant-numeric: tabular-nums; }
.cpg-console-level, .cpg-console-kind { overflow: hidden; color: var(--ops-text-muted); font-size: 9px; font-weight: 700; letter-spacing: .07em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.cpg-console-main strong { min-width: 0; overflow-wrap: anywhere; color: var(--ops-text); font-weight: 600; }
.cpg-console-isolate { min-height: 27px; padding: 0 8px; font-size: 10px; }
.cpg-console-request { margin: 7px 0 0 248px; color: var(--ops-text-muted); overflow-wrap: anywhere; }
.cpg-console-meta { display: flex; gap: 16px; flex-wrap: wrap; margin: 5px 0 0 248px; color: var(--ops-text-faint); font-size: 9px; }
.cpg-console-line details { margin: 6px 0 0 248px; }
.cpg-console-line summary { color: var(--ops-text-faint); cursor: pointer; font-size: 9px; }
.cpg-console-line.level-error, .cpg-console-line.level-error .cpg-console-main strong,
.cpg-console-line.level-error .cpg-console-level { color: var(--red, var(--danger)); }
.cpg-console-line.level-warn .cpg-console-level { color: var(--ops-warning); }
.cpg-console-foot { display: flex; justify-content: center; padding: 12px; border: 1px solid var(--ops-line); border-top: 0; border-radius: 0 0 10px 10px; background: var(--ops-bg); }

@media (max-width: 820px) {
  .cpg-ops-head { align-items: flex-start; flex-direction: column; gap: 8px; }
  .cpg-ops-toolbar { align-items: stretch; }
  .cpg-ops-field { flex: 1 1 130px; }
  .cpg-console-main { grid-template-columns: 1fr auto auto; }
  .cpg-console-main time { grid-column: 1 / -1; }
  .cpg-console-main strong { grid-column: 1 / 3; }
  .cpg-console-request, .cpg-console-meta, .cpg-console-line details { margin-left: 0; }
}

@media (max-width: 540px) {
  .cpg-ops-search { flex-basis: 100%; min-width: 100%; }
  .cpg-ops-view button span { display: none; }
  .cpg-ops-detail-grid { grid-template-columns: 1fr; }
  .cpg-console-main { grid-template-columns: auto 1fr auto; }
  .cpg-console-main strong { grid-column: 1 / -1; }
  .cpg-console-isolate span { display: none; }
}

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