/* Redesign shell + primitives (REDESIGN_SPEC.md par.1-3); unlayered on purpose - must outrank legacy layered CSS. */

/* ---------- Page shell ---------- */

.rd-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Instrument Sans', sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

.rd-page {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Instrument Sans', sans-serif;
}

.crs-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.crs-content {
  padding: 28px 32px 48px;
  max-width: 1240px;
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto;
}

/* ---------- Sidebar ---------- */

.crs-side {
  width: 248px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  box-sizing: border-box;
}

.crs-side__brand {
  padding: 20px 20px 16px;
}

.crs-side__user {
  margin-top: auto;
  border-top: 1px solid var(--border);
  box-sizing: border-box;
  height: 62px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.crs-side__avatar {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.crs-side__user-info {
  min-width: 0;
  flex: 1;
}

.crs-side__user-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crs-side__user-role {
  font-size: 11.5px;
  color: var(--faint);
}

.crs-side__logout {
  background: none;
  border: none;
  color: var(--faint);
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.crs-side__logout:hover {
  color: var(--text);
  background: var(--accent-fade);
  text-decoration: none;
}

.crs-side__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 18px 12px;
}

.crs-side__item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
}

.crs-side__item:hover {
  text-decoration: none;
}

.crs-side__item:hover {
  background: var(--accent-fade);
}

.crs-side__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
  flex-shrink: 0;
}

.crs-side__item.is-active {
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-fade);
}

.crs-side__item.is-active .crs-side__dot {
  border-radius: 2px;
}

/* ---------- Topbar ---------- */

.crs-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 5;
}

.crs-top__crumb {
  font-size: 13px;
  color: var(--muted);
}

.crs-top__crumb a {
  color: var(--accent);
  text-decoration: none;
}

.crs-top__crumb a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.crs-top__theme {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel2);
  border: 1px solid var(--border2);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.crs-top__theme:hover {
  color: var(--text);
  border-color: var(--accent);
}

.crs-top__theme-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------- Footer ---------- */

.crs-foot {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--panel);
  padding: 16px 32px;
  display: flex;
  height: 62px;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  color: var(--muted);
}

.crs-foot strong {
  color: var(--text);
}

.crs-foot__sig {
  color: var(--faint);
}

/* ---------- Primitives ---------- */

.rd-h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.rd-sub {
  margin-top: 6px;
  font-size: 13.5px;
  color: var(--muted);
}

.rd-kicker {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
}

.rd-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.rd-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  padding: 9px 18px;
  cursor: pointer;
  white-space: nowrap;
  box-sizing: border-box;
  border: 1px solid transparent;
}

.rd-btn--primary {
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  box-shadow: var(--shadow);
}

.rd-btn--primary:hover {
  background: var(--accent-hover);
}

.rd-btn--soft {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in oklab, var(--accent) 35%, transparent);
}

.rd-btn--soft:hover {
  background: var(--accent);
  color: var(--on-accent);
}

.rd-btn--ghost {
  background: none;
  border: 1px solid var(--border2);
  color: var(--muted);
  font-weight: 500;
}

.rd-btn--ghost:hover {
  color: var(--text);
  border-color: var(--accent);
}

.rd-btn--danger {
  background: var(--danger);
  color: #fff;
  border: none;
}

.rd-btn--danger:hover {
  background: color-mix(in oklab, var(--danger) 85%, black);
}

.rd-input {
  background: var(--input);
  border: 1px solid var(--border2);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  padding: 10px 12px;
  border-radius: 9px;
  outline: none;
  box-sizing: border-box;
}

.rd-input:focus {
  border-color: var(--accent);
}

.rd-input--mono {
  font-family: 'IBM Plex Mono', monospace;
}

select.rd-input {
  padding: 9px 10px;
  font-size: 13px;
}

.rd-mono {
  font-family: 'IBM Plex Mono', monospace;
}

/* ---------- Toggle switch ---------- */

.rd-switch {
  display: inline-block;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--panel2);
  border: 1px solid var(--border2);
  position: relative;
  vertical-align: middle;
  transition: background 0.15s;
  box-sizing: border-box;
}

.rd-switch__knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: left 0.15s;
}

.rd-switch--on {
  background: var(--accent);
  border-color: var(--accent);
}

.rd-switch--on .rd-switch__knob {
  left: 17px;
}

/* ---------- Modal ---------- */

.rd-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(3px);
  z-index: 50;
  overflow: auto;
}

.rd-modal__panel {
  background: var(--panel);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  width: 420px;
  max-width: calc(100vw - 48px);
  box-sizing: border-box;
  margin: 16vh auto 40px;
}

.rd-modal__panel--wide {
  width: 480px;
  margin-top: 8vh;
}

.rd-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.rd-modal__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.rd-modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* ---------- Right-side drawer (lives inside an .rd-modal overlay) ---------- */

.rd-drawer {
  background: var(--panel);
  border-left: 1px solid var(--border2);
  box-shadow: var(--shadow);
  width: 420px;
  max-width: calc(100vw - 40px);
  height: 100vh;
  margin-left: auto;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.rd-drawer__head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.rd-drawer__sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 4px;
}

.rd-drawer__tools {
  padding: 14px 24px 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.rd-drawer__tools .rd-input {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  padding: 8px 12px;
}

.rd-drawer__body {
  flex: 1;
  overflow: auto;
  padding: 8px 12px;
}

.rd-drawer__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.rd-drawer__item:hover {
  background: var(--accent-fade);
}

.rd-drawer__item-name {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rd-drawer__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* Visual checkbox used in drawer lists. */
.rd-check {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  border: 1.5px solid var(--border2);
  background: var(--input);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  box-sizing: border-box;
}

.rd-check__mark {
  display: none;
}

.is-on > .rd-check {
  background: var(--accent);
  border-color: var(--accent);
}

.is-on > .rd-check .rd-check__mark {
  display: inline;
}

/* ---------- Shared modal form bits ---------- */

/* Modal close glyph (span.close/.close2 - the page JS binds by class). */
.close,
.close2 {
  color: var(--muted);
  float: right;
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}

.close:hover,
.close2:hover {
  color: var(--text);
}

.idx-modal-input {
  width: 100%;
  margin-bottom: 2px;
}

.idx-modal-note {
  font-size: 12px;
  color: var(--faint);
  margin-top: 8px;
}

/* Danger confirm modal body. */
.idx-confirm {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.idx-confirm__icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: color-mix(in oklab, var(--danger) 14%, transparent);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
  flex-shrink: 0;
}

.idx-confirm__msg {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

/* ---------- Segmented filter ---------- */

.rd-seg {
  display: flex;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
}

.rd-seg__btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
}

.rd-seg__btn.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Server-rendered <a> pills: neutralize the base link styles with matching force. */
.rd-seg a.rd-seg__btn,
.rd-seg a.rd-seg__btn:hover {
  color: var(--muted);
  text-decoration: none;
}

.rd-seg a.rd-seg__btn:hover {
  color: var(--text);
}

.rd-seg a.rd-seg__btn.is-active,
.rd-seg a.rd-seg__btn.is-active:hover {
  color: var(--accent);
}

/* ---------- Page header + toolbar ---------- */

.rd-pagehead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.rd-toolbar {
  margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.rd-search {
  flex: 1;
  min-width: 220px;
  width: auto;
  font-size: 13.5px;
  padding: 11px 16px;
  border-radius: 10px;
}

/* Page-level kebab: bordered trigger per the design's toolbar. */
.rd-page-menu__trigger.btn-icon {
  border: 1px solid var(--border2);
  border-radius: 9px;
  padding: 6px 10px;
  color: var(--muted);
}

.rd-page-menu__trigger.btn-icon:hover,
.rd-page-menu.is-open .rd-page-menu__trigger.btn-icon {
  background: none;
  color: var(--text);
  border-color: var(--accent);
}

/* Full-screen busy overlay (#sr31); CrsAdmin.show overrides the CSS-hidden state. */
.rd-loader {
  display: none;
  text-align: center;
  position: fixed;
  width: 100%;
  top: 50%;
  z-index: 999;
}

/* ---------- Data table (projects / experiments / users listings) ---------- */

.rd-tablecard {
  overflow: visible;
}

/* separate (not collapse): cell border-radius is ignored in collapse mode, and the last row's hover must round with the card. */
.rd-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.rd-th {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
}

.rd-th--right {
  text-align: right;
  padding-right: 12px;
}

.rd-th:first-child,
.rd-row > td:first-child {
  padding-left: 20px;
}

.rd-col-toggle { width: 64px; }
.rd-col-type { width: 120px; }
.rd-col-url { width: 170px; }
.rd-col-enter { width: 90px; text-align: center; }
.rd-col-sched { width: 210px; }
.rd-col-cookie { width: 110px; }
.rd-col-actions { width: 44px; }

/* Separator on the TOP of following rows: the last visible row must not draw over the card's rounded bottom, and :last-child can't see index.php's trailing hidden rows. */
.rd-row ~ .rd-row > td {
  border-top: 1px solid var(--border);
}

/* Hover paints the cells (a tr background would ignore the corner radius below). */
.rd-row:hover > td {
  background: var(--accent-fade);
}

/* Round the last row's corner cells with the card; :last-child table = no pager below it; the + td arm covers viewer rows whose first cell is hidden. */
.rd-table:last-child .rd-row:nth-last-child(1 of .rd-row) > td:first-child,
.rd-table:last-child .rd-row:nth-last-child(1 of .rd-row) > td.u-hidden:first-child + td {
  border-bottom-left-radius: calc(var(--radius) - 1px);
}

.rd-table:last-child .rd-row:nth-last-child(1 of .rd-row) > td:last-child {
  border-bottom-right-radius: calc(var(--radius) - 1px);
}

.rd-row > td {
  padding: 11px 8px;
  vertical-align: middle;
}

/* Clickable cells: the delegated-click hook classes double as the cursor cue. */
.rd-row > .cm,
.rd-row > .cmm1,
.rd-row > .propid,
.rd-row > .plusminus {
  cursor: pointer;
}

.rd-row > .plusminus {
  white-space: nowrap;
}

.rd-cell-name {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
}

.rd-cell-name:hover {
  color: var(--accent);
}

.rd-cell-enter {
  text-align: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px;
  color: var(--text);
}

.rd-sched-start {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
}

.rd-sched-finish {
  font-size: 11.5px;
  color: var(--faint);
  white-space: nowrap;
}

.rd-cell-cookie {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-actions {
  position: relative;
  text-align: right;
  white-space: nowrap;
  padding-right: 12px;
}

.rd-empty {
  padding: 28px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Shared modal form bits (labels + report output) ---------- */

.rd-form-label {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
  margin: 12px 0 6px;
}

.rd-report-out {
  max-height: 60vh;
  overflow: auto;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}
