/*
 * Application styles for the server-rendered Keymaster UI.
 */

:root {
  color-scheme: light;
  --bg: #f4f5f6;
  --panel: #ffffff;
  --ink: #20262d;
  --muted: #6d7782;
  --line: #d9dde2;
  --line-dark: #c5cbd2;
  --accent: #0b7285;
  --accent-dark: #075b6a;
  --danger: #9d3224;
  --pending: #f7c948;
  --warn-bg: #fff6d8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.35;
}

button,
input,
textarea {
  font: inherit;
}

.page-shell {
  margin: 0 auto;
  max-width: 920px;
  padding: 24px;
}

.page-header {
  align-items: center;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.home-title-row {
  align-items: center;
  display: flex;
  gap: 10px;
}

.page-header h1,
.matrix-topbar h1 {
  font-size: 24px;
  line-height: 1.1;
  margin: 0;
}

.eyebrow,
.app-row small {
  color: var(--muted);
  display: block;
  font-size: 11px;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

.app-list {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.app-row {
  align-items: center;
  color: inherit;
  display: flex;
  justify-content: space-between;
  min-height: 58px;
}

.app-row-link {
  align-items: center;
  color: inherit;
  display: flex;
  flex: 1;
  justify-content: space-between;
  padding: 14px 16px;
  text-decoration: none;
}

.app-row + .app-row {
  border-top: 1px solid var(--line);
}

.app-row:hover {
  background: #edf7f8;
}

.app-row form {
  margin: 0 12px 0 0;
}

.access-shell {
  margin: 0 auto;
  max-width: 980px;
  padding: 28px 24px 48px;
}

.access-section-heading,
.access-binding,
.access-grant-command {
  align-items: center;
  display: flex;
}

.access-section-heading h2 {
  margin: 0;
}

.access-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-top: 16px;
}

.access-section-heading {
  border-bottom: 1px solid var(--line);
  justify-content: space-between;
  padding: 13px 15px;
}

.access-section-heading h2 {
  font-size: 16px;
}

.access-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  margin-left: 4px;
}

.access-grant-form {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 15px;
}

.access-invitation-form,
.pending-grant-list {
  display: grid;
  gap: 1rem;
}

.access-invitation-form > .access-field {
  margin-left: 15px;
  width: min(100%, 420px);
}

.access-invitation-form .access-grant-command {
  margin-bottom: 15px;
  margin-left: 15px;
}

.pending-grant-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 0.75rem;
  align-items: end;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
}

.machine-credential-form {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 15px;
}

.machine-credential-form input:not([type="submit"]),
.machine-credential-form select {
  background: #fff;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  color: var(--ink);
  min-width: 0;
  padding: 7px 8px;
  width: 100%;
}

.machine-credential-command {
  align-items: center;
  display: flex;
  gap: 10px;
  grid-column: 1 / -1;
}

.machine-credential-issued {
  padding: 15px;
}

.machine-credential-issued p {
  max-width: 620px;
}

.machine-credential-token {
  background: #f7f9fb;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  box-sizing: border-box;
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  margin: 14px 0;
  min-height: 84px;
  padding: 10px;
  resize: vertical;
  width: 100%;
}

.access-field {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  gap: 5px;
}

.access-field input,
.access-field select {
  background: #fff;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  color: var(--ink);
  min-width: 0;
  padding: 7px 8px;
  width: 100%;
}

.access-grant-command {
  gap: 10px;
  grid-column: 1 / -1;
}

.access-empty {
  color: var(--muted);
  margin: 0;
  padding: 15px;
}

.access-binding-list {
  display: grid;
}

.access-binding {
  border-bottom: 1px solid var(--line);
  justify-content: space-between;
  padding: 12px 15px;
}

.access-binding:last-child {
  border-bottom: 0;
}

.access-binding strong,
.access-binding span,
.access-binding small {
  display: block;
  overflow-wrap: anywhere;
}

.access-binding span,
.access-binding small {
  color: var(--muted);
  font-size: 12px;
}

.matrix-shell {
  background: #eef0f2;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
  position: relative;
}

.matrix-sidebar {
  background: #252b31;
  color: #f7f8f9;
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  position: sticky;
  top: 0;
}

.sidebar-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.sidebar-footer {
  border-top: 1px solid #3a424a;
  flex: 0 0 auto;
}

.account-menu-container {
  position: relative;
}

.sidebar-brand {
  border-bottom: 1px solid #3a424a;
  display: flex;
  justify-content: center;
  padding: 14px 0;
}

.brand-logo-full {
  display: block;
  height: auto;
  margin: 0 auto;
  max-width: 100%;
  object-fit: contain;
  width: 60%;
}

.sidebar-profile {
  align-items: center;
  background: transparent;
  border: 0;
  color: #f7f8f9;
  cursor: pointer;
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  text-align: left;
  width: 100%;
}

.sidebar-profile:hover {
  background: #333b44;
}

.sidebar-profile strong,
.sidebar-profile small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-profile small {
  color: #aab3bc;
  font-size: 12px;
}

.sidebar-profile strong {
  color: #f7f8f9;
  font-size: 13px;
}

.avatar-circle {
  align-items: center;
  background: var(--avatar-color, var(--accent));
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  flex: 0 0 auto;
  font-weight: 700;
  height: 34px;
  justify-content: center;
  overflow: hidden;
  width: 34px;
}

.avatar-image {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.home-brand {
  align-items: center;
  display: flex;
  gap: 8px;
}

.home-brand-logo {
  height: 26px;
  object-fit: contain;
  width: 26px;
}

.current-user,
.home-profile-button {
  align-items: center;
  display: flex;
  gap: 10px;
}

.home-profile-button {
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  padding: 0;
}

.account-menu {
  background: #fff;
  border: 1px solid #d4dae0;
  border-radius: 6px;
  box-shadow: 0 12px 28px rgba(24, 35, 45, 0.18);
  min-width: 176px;
  opacity: 0;
  padding: 4px;
  pointer-events: none;
  position: absolute;
  transform: translateY(6px) scale(0.96);
  transition: opacity 140ms ease, transform 140ms ease, visibility 140ms ease;
  visibility: hidden;
  z-index: 20;
}

.account-menu.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  visibility: visible;
}

.sidebar-account-menu-container .account-menu {
  bottom: calc(100% + 8px);
  left: 8px;
  transform-origin: bottom left;
}

.home-account-menu-container .account-menu {
  right: 0;
  top: calc(100% + 8px);
  transform-origin: top right;
}

.account-menu-item {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 5px;
  color: #252b31;
  cursor: pointer;
  display: flex;
  font: inherit;
  gap: 9px;
  min-height: 36px;
  padding: 8px 10px;
  text-align: left;
  text-decoration: none;
  transition: background-color 120ms ease, color 120ms ease, transform 120ms ease;
  width: 100%;
}

.account-menu-icon {
  flex: 0 0 auto;
  height: 17px;
  width: 17px;
}

.account-menu-item:hover,
.account-menu-item:focus-visible {
  background: #e7f0ff;
  color: #0b57a7;
  outline: 0;
  transform: translateX(2px);
}

.account-menu-item:focus-visible {
  box-shadow: 0 0 0 2px #75a7e6;
}

.account-menu-sign-out {
  color: #b42318;
}

.account-menu-sign-out:hover,
.account-menu-sign-out:focus-visible {
  background: #fff0ee;
  color: #a51d14;
}

.account-menu-sign-out-form {
  margin: 0;
}

.account-menu-divider {
  border-top: 1px solid #e2e7ec;
  margin: 4px 6px;
}

.sidebar-app-list {
  display: grid;
  gap: 2px;
}

.sidebar-app {
  align-items: center;
  border-radius: 4px;
  color: #f7f8f9;
  display: flex;
  justify-content: space-between;
  min-height: 30px;
  padding: 6px 8px;
  text-decoration: none;
}

.sidebar-app:hover {
  background: #333b44;
}

.sidebar-app.active {
  background: #333b44;
  font-weight: 700;
}

.sidebar-app.disabled {
  color: #aab3bc;
  cursor: not-allowed;
}

.sidebar-app-actions {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.sidebar-config-button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 4px;
  color: #aab3bc;
  cursor: pointer;
  display: inline-flex;
  font-size: 13px;
  height: 22px;
  justify-content: center;
  padding: 0;
  width: 22px;
}

.sidebar-config-button:hover {
  background: rgb(255 255 255 / 12%);
  color: #20262d;
}

.sidebar-section {
  border-bottom: 1px solid #3a424a;
  padding: 12px 14px;
}

.sidebar-section h2 {
  color: #aab3bc;
  font-size: 11px;
  font-weight: 700;
  margin: 0;
  text-transform: uppercase;
}

.sidebar-section-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.stage-cell-button,
.header-icon-button,
.app-remove-button,
.sidebar-add-button,
.pending-remove-button {
  align-items: center;
  background: var(--accent);
  border: 0;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 30px;
  min-width: 30px;
  padding: 0 8px;
}

.app-remove-button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--danger);
  min-height: 30px;
  min-width: 30px;
  padding: 0;
}

.app-remove-button:hover {
  background: #f9e1de;
  border-color: #e6b0aa;
}

.sidebar-add-button {
  background: transparent;
  color: #8fc6be;
  min-height: 22px;
  min-width: 22px;
  padding: 0;
}

.sidebar-add-button:hover {
  background: #333b44;
}

.matrix-workspace {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

.matrix-title {
  align-items: center;
  display: flex;
  gap: 12px;
}

.matrix-topbar {
  align-items: center;
  background: #f8f9fa;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  min-height: 68px;
  padding: 14px 18px;
}

.matrix-topbar .eyebrow {
  color: var(--muted);
}

.topbar-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.compact-button {
  margin-left: 10px;
  min-height: 32px;
}

.icon-toggle-button {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  min-width: 38px;
  padding: 0 10px;
}

.icon-toggle-button:hover {
  border-color: #9fb4b1;
}

.icon-toggle-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.icon-toggle-button .icon-eye-off {
  display: none;
}

.icon-toggle-button.active .icon-eye {
  display: none;
}

.icon-toggle-button.active .icon-eye-off {
  display: inline;
}

.matrix-layout {
  align-items: start;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr);
  padding: 12px 12px 0;
}

.matrix-footer {
  align-items: center;
  /* Sits at the bottom of the viewport even when there are only a few keys. */
  margin-top: auto;
  background: #f8f9fa;
  border-top: 1px solid var(--line);
  bottom: 0;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 10px 12px;
  position: sticky;
  /* Above the sticky key column (z-index 3) and header corner (4) so the
     last row doesn't bleed through the footer at the bottom of the scroll. */
  z-index: 5;
}

.footer-pending {
  color: var(--muted);
  font-weight: 700;
}

.footer-pending.has-pending {
  background: #fff4bf;
  border: 1px solid #e5c653;
  border-radius: 4px;
  color: #5e4700;
  padding: 6px 8px;
}

.footer-actions {
  display: flex;
  gap: 8px;
}

.footer-actions form {
  margin: 0;
}

.matrix-editor {
  min-width: 0;
}

.matrix-frame {
  background: var(--panel);
  border: 1px solid #c8ced5;
  border-radius: 6px;
  box-shadow: 0 1px 2px rgb(16 24 32 / 5%);
  max-height: calc(100vh - 150px);
  overflow: auto;
}

.matrix-table {
  border-collapse: collapse;
  /* Key column plus a comfortable minimum per environment; more than three scroll. */
  min-width: calc(230px + var(--environment-count, 3) * 220px);
  table-layout: fixed;
  width: 100%;
}

.matrix-table th,
.matrix-table td {
  border-bottom: 1px solid #dde2e6;
  border-right: 1px solid #dde2e6;
  padding: 0;
  text-align: left;
  vertical-align: top;
}

.matrix-table th:last-child,
.matrix-table td:last-child {
  border-right: 0;
}

.matrix-table thead th {
  background: #2f6661;
  border-bottom: 1px solid #25534f;
  color: #fff;
  min-width: 215px;
  padding: 9px 10px;
  position: sticky;
  top: 0;
  z-index: 2;
}

.matrix-table thead .key-column {
  background: #2b3138;
  left: 0;
  z-index: 4;
}

.matrix-table tbody .key-column {
  left: 0;
  position: sticky;
  z-index: 3;
}

.matrix-key-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.header-icon-button {
  background: #fff;
  color: var(--accent-dark);
}

.key-column {
  background: #f6f7f8;
  width: 230px;
}

.key-column[scope="row"] {
  padding: 8px 10px;
}

.key-name,
.environment-name {
  display: block;
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

/* Key cell head: name (left, editable) + stacked action icons (top-right) */
.key-column-head {
  align-items: flex-start;
  display: flex;
  gap: 6px;
  justify-content: space-between;
}

.key-name-area {
  flex: 1 1 auto;
  min-width: 0;
}

.key-row-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 2px;
}

/* Secondary key actions stay out of the way until the row is in use. */
.key-row-secondary,
.key-column:not(.is-sensitive) .key-sensitivity-toggle {
  opacity: 0;
}

tr:hover .key-row-secondary,
tr:focus-within .key-row-secondary,
tr:hover .key-column:not(.is-sensitive) .key-sensitivity-toggle,
tr:focus-within .key-column:not(.is-sensitive) .key-sensitivity-toggle {
  opacity: 1;
}

.key-lock {
  color: var(--muted);
  display: inline-flex;
  height: 22px;
  width: 22px;
}

.key-lock svg {
  height: 15px;
  margin: auto;
  width: 15px;
}

.key-icon-button {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  min-height: 22px;
  min-width: 22px;
  padding: 0;
}

.key-icon-button svg {
  height: 15px;
  width: 15px;
}

.key-icon-button:hover {
  border-color: #9fb4b1;
  color: var(--ink);
}

.key-icon-button.danger {
  color: var(--danger);
}

.key-icon-button.danger:hover {
  background: #fbeaea;
  border-color: var(--danger);
}

/* Inline key rename: double-click the name to edit (mirrors environment names) */
.key-name-display {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: text;
  display: block;
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
  padding: 2px 4px;
  text-align: left;
  width: 100%;
}

.key-name-display:hover,
.key-name-display:focus {
  border-color: var(--line-dark);
  outline: 0;
}

.key-name-display:focus-visible {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.key-name-display[hidden] {
  display: none;
}

.key-name-editor[hidden] {
  display: none;
}

.key-name-input {
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  font-size: 14px;
  font-weight: 700;
  min-height: 30px;
  padding: 4px 6px;
  width: 100%;
}

.key-name-warning {
  color: var(--danger);
  font-size: 11px;
  margin: 4px 0 0;
}

.key-name-warning[hidden] {
  display: none;
}

.key-name-warning code {
  overflow-wrap: anywhere;
}

.environment-header {
  min-height: 31px;
}

.environment-name-display {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #fff;
  cursor: text;
  display: block;
  font-size: 14px;
  font-weight: 700;
  max-width: 100%;
  overflow: hidden;
  padding: 3px 4px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.environment-name-display:hover,
.environment-name-display:focus {
  border-color: rgb(255 255 255 / 55%);
  outline: 0;
}

.environment-name-display:focus-visible {
  border-color: rgb(255 255 255 / 55%);
  outline: 2px solid #fff;
  outline-offset: 1px;
}

.environment-name-editor {
  align-items: center;
  display: flex;
  gap: 5px;
}

.environment-name-editor[hidden] {
  display: none;
}

.environment-name-input {
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  min-height: 30px;
  min-width: 0;
  padding: 5px 7px;
  width: 130px;
}

.key-description {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 4px;
}

.cell-status {
  color: #59636e;
  display: block;
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  padding: 0 9px 6px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.staged-cell .cell-status {
  color: #6b5200;
}

.missing-cell .cell-status {
  color: #7a5a00;
}

.missing-cell .value-button {
  border-style: dashed;
}

.missing-production {
  background: #fdf3f1;
}

.missing-production .cell-status {
  color: var(--danger);
}

.cell-inspect-button {
  background: #fff;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  min-height: 22px;
  min-width: 22px;
  padding: 0 5px;
}

.cell-inspect-button:hover {
  border-color: #9fb4b1;
  color: var(--ink);
}

.cell-value {
  align-items: center;
  display: flex;
  gap: 6px;
  padding: 6px 8px;
  position: relative;
}

/* Copy and details sit over the end of the value instead of reserving space. */
.cell-tools {
  display: flex;
  gap: 4px;
  opacity: 0;
  position: absolute;
  right: 12px;
  transition: opacity 120ms ease;
}

.matrix-cell:hover .cell-tools,
.matrix-cell.selected-cell .cell-tools {
  opacity: 1;
}

.cell-tools .copy-button,
.cell-tools .cell-inspect-button {
  min-height: 24px;
  min-width: 24px;
  padding: 0 5px;
}

.cell-value.editing {
  align-items: stretch;
  gap: 5px;
}

.cell-value.editing .value-button,
.cell-value.editing .cell-tools {
  display: none;
}

.value-button {
  background: transparent;
  border: 1px solid #e8ecef;
  border-radius: 4px;
  color: inherit;
  cursor: text;
  display: block;
  flex: 1;
  height: 34px;
  min-height: 31px;
  min-width: 0;
  overflow: hidden;
  padding: 6px 7px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: normal;
}

.value-button code {
  overflow: hidden;
  text-overflow: ellipsis;
}

.value-button.masked {
  color: var(--muted);
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  letter-spacing: 1px;
}

.value-button:focus {
  border-color: var(--accent);
  outline: 0;
}

.value-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.value-button:hover,
.copy-button:hover {
  border-color: #9fb4b1;
}

.copy-button {
  background: #fff;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  flex: 0 0 auto;
  font-size: 11px;
  min-height: 30px;
  min-width: 30px;
  padding: 4px 7px;
}


.value-display {
  background: #f4f6f7;
  border-radius: 4px;
  display: block;
  min-height: 31px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 7px;
  white-space: nowrap;
  word-break: normal;
}

.cell-editor {
  display: flex;
  flex: 1;
  gap: 5px;
  min-width: 0;
  position: relative;
}

.cell-editor[hidden] {
  display: none;
}

.matrix-input {
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  flex: 1 1 auto;
  min-height: 31px;
  min-width: 0;
  padding: 5px 7px;
  width: 100%;
}

.inherit-menu {
  background: #fff;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  box-shadow: 0 10px 22px rgb(0 0 0 / 18%);
  display: grid;
  gap: 2px;
  max-height: 240px;
  min-width: 170px;
  overflow: auto;
  padding: 4px;
  position: fixed;
  z-index: 70;
}

.inherit-menu[hidden] {
  display: none;
}

.inherit-menu-item {
  background: transparent;
  border: 0;
  border-radius: 4px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  padding: 7px 9px;
  text-align: left;
  white-space: nowrap;
}

.inherit-menu-item:hover {
  background: #eef7f8;
}

.inherit-menu-item.current {
  color: var(--accent-dark);
  font-weight: 700;
}

.inherit-trigger-button {
  background: #fff;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  flex: 0 0 auto;
  min-height: 31px;
  min-width: 31px;
  padding: 4px 7px;
}

.inherit-trigger-button:hover {
  border-color: #9fb4b1;
  color: var(--ink);
}

.matrix-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.matrix-cell {
  background: #fff;
  cursor: default;
}

.matrix-cell:hover {
  background: #f7fbfb;
}

.matrix-cell.selected-cell {
  box-shadow: inset 0 0 0 2px #3d7f78;
  position: relative;
}

.staged-cell {
  background: #fff8d6;
}

.staged-cell:hover {
  background: #fff4bf;
}

.edited-cell {
  background: #fffdf0;
}

.hidden-form {
  display: none;
}

.footer-apply-form {
  margin: 0;
}

.pending-remove-button {
  background: transparent;
  color: var(--muted);
  min-height: 24px;
  min-width: 24px;
  padding: 0;
}

.pending-remove-button:hover {
  background: #f7e7e4;
  color: var(--danger);
}

.production-warning {
  background: var(--warn-bg);
  border: 1px solid #ead38d;
  border-radius: 4px;
  margin: 0;
  padding: 8px;
}

.primary-button,
.secondary-button,
.link-button {
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  min-height: 32px;
  padding: 7px 10px;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-dark);
}

.secondary-button {
  background: #ffffff;
  border-color: var(--line-dark);
  color: var(--ink);
  margin: 12px;
}

.no-margin {
  margin: 0;
}

.link-button {
  background: transparent;
  color: var(--muted);
  padding-inline: 0;
}

.danger-button {
  background: #fff;
  border: 1px solid #e6b0aa;
  border-radius: 4px;
  color: var(--danger);
  cursor: pointer;
  min-height: 32px;
  padding: 7px 10px;
}

.danger-button:hover {
  background: #f9e1de;
  border-color: #d99a91;
}

.primary-button.production-apply {
  background: var(--danger);
}

.primary-button.production-apply:hover {
  background: #7f271b;
}

.notice {
  background: #e2f4f7;
  border: 1px solid #a8d8d1;
  border-radius: 6px;
  box-shadow: 0 10px 28px rgb(0 0 0 / 14%);
  left: 50%;
  margin: 0;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 12px;
  position: fixed;
  text-align: center;
  top: 18px;
  transform: translateX(-50%);
  width: max-content;
  z-index: 90;
}

.notice.alert {
  background: var(--warn-bg);
  border-color: #ead38d;
}

.notice[hidden] {
  display: none;
}

.toast {
  background: #0b7285;
  border: 1px solid #075b6a;
  border-radius: 6px;
  box-shadow: 0 10px 28px rgb(0 0 0 / 18%);
  color: #fff;
  left: 50%;
  min-width: 220px;
  padding: 11px 14px;
  position: fixed;
  text-align: center;
  top: 18px;
  transform: translateX(-50%);
  z-index: 80;
}

.toast[hidden] {
  display: none;
}

.value-modal {
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  max-width: min(560px, 92vw);
  padding: 0;
  width: 540px;
}

.small-modal {
  width: 380px;
}

.environment-management-modal {
  width: min(680px, 94vw);
}

.value-modal::backdrop {
  background: rgb(0 0 0 / 35%);
}

.value-modal header {
  align-items: center;
  background: #eef1f4;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
}

.value-modal h2 {
  font-size: 15px;
  margin: 0;
}

.value-modal pre {
  margin: 0;
  max-height: 60vh;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-form {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.modal-form input[type="text"],
.modal-form input[type="file"],
.modal-form textarea {
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  padding: 8px;
  width: 100%;
}

.modal-form label {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 6px;
}

.modal-form .field-label {
  align-items: stretch;
  color: var(--muted);
  display: grid;
  font-size: 12px;
  gap: 4px;
}

.modal-form footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.settings-layout {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  min-height: 320px;
}

.settings-tabs {
  background: #f7f8f9;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
}

.settings-tab {
  background: transparent;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  padding: 8px;
  text-align: left;
}

.settings-tab:hover,
.settings-tab.active {
  background: #e7eaed;
  color: var(--ink);
}

.settings-content {
  min-width: 0;
}

.settings-panel {
  min-width: 0;
}

.settings-form {
  border-bottom: 1px solid var(--line);
}

.settings-danger-zone {
  align-items: center;
  border: 1px solid #e6b0aa;
  border-radius: 6px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin: 4px 12px 12px;
  padding: 10px 12px;
}

.settings-danger-zone h3 {
  color: var(--danger);
  font-size: 13px;
  margin: 0;
}

.settings-danger-zone p {
  color: var(--muted);
  margin: 2px 0 0;
}

.settings-checkbox {
  align-items: flex-start !important;
}

.settings-checkbox span {
  color: var(--ink);
  display: grid;
  gap: 2px;
}

.settings-checkbox small {
  color: var(--muted);
  font-size: 12px;
}

.environment-management-list {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  max-height: 60vh;
  overflow: auto;
  padding: 12px;
}

.environment-add-form {
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.85fr);
}

.environment-add-form label {
  align-self: center;
}

.environment-add-form footer {
  grid-column: 1 / -1;
}

.environment-management-row {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  display: grid;
  gap: 4px 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 8px;
}

.environment-management-name {
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.environment-badge {
  background: #fdf3f1;
  border: 1px solid #e6b0aa;
  border-radius: 999px;
  color: var(--danger);
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
  padding: 1px 7px;
}

.environment-troubleshooting {
  grid-column: 1 / -1;
}

.environment-troubleshooting summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.environment-troubleshooting p {
  margin: 6px 0 4px;
}

.fingerprint-copy {
  display: flex;
  gap: 6px;
}

.fingerprint-copy input {
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  min-width: 0;
  padding: 6px 8px;
}

.environment-management-actions {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.environment-management-actions form {
  margin: 0;
}

.environment-management-lock {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.color-swatch-group {
  border: 0;
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.color-swatch-group legend {
  color: var(--muted);
  flex: 0 0 100%;
  font-size: 12px;
  margin-bottom: 2px;
}

.color-swatch {
  cursor: pointer;
  display: inline-flex;
}

.color-swatch input {
  position: absolute;
  opacity: 0;
}

.color-swatch span {
  background: var(--swatch-color);
  border: 2px solid #fff;
  border-radius: 999px;
  box-shadow: 0 0 0 1px var(--line-dark);
  display: block;
  height: 24px;
  width: 24px;
}

.color-swatch input:checked + span {
  box-shadow: 0 0 0 3px var(--accent);
}

.profile-image-preview {
  align-items: center;
  display: flex;
  gap: 12px;
}

.profile-image-thumb {
  border-radius: 999px;
  display: block;
  height: 48px;
  object-fit: cover;
  width: 48px;
}

.modal-textarea {
  min-height: 360px;
  resize: both;
}

.empty-state,
.cell-error {
  background: var(--warn-bg);
  border: 1px solid #ead38d;
  border-radius: 4px;
  margin: 12px;
  padding: 10px 12px;
}

/* Workbench detail surface: one right slide-over hosting the inspector or the change review. */
.matrix-panel {
  background: #fff;
  border-left: 1px solid #c8ced5;
  box-shadow: -8px 0 24px rgb(16 24 32 / 12%);
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 92vw;
  overflow: hidden;
  position: fixed;
  right: 0;
  top: 0;
  transform: translateX(100%);
  transition: transform 160ms ease;
  width: 360px;
  z-index: 60;
}

.matrix-panel.open {
  transform: translateX(0);
}

.matrix-panel[hidden] {
  display: none;
}

.panel-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
}

.panel-section[hidden] {
  display: none;
}

.panel-close {
  background: transparent;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  margin-left: auto;
  padding: 2px 8px;
}

.panel-close:hover {
  background: #eef1f4;
  color: var(--ink);
}

.inspector-panel,
.change-cart {
  background: #fff;
  overflow: hidden;
}

.panel-heading {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 8px;
  padding: 12px 13px;
}

.panel-heading h2 {
  font-size: 16px;
  line-height: 1.2;
  margin: 0;
  overflow-wrap: anywhere;
}

.inspector-empty,
.cart-empty {
  color: var(--muted);
  padding: 13px;
}

.inspector-body[hidden],
.inspector-empty[hidden],
.inspector-reveal[hidden] {
  display: none;
}

.inspector-body {
  display: grid;
  gap: 13px;
  padding: 13px;
}

.inspector-facts {
  display: grid;
  gap: 8px;
  margin: 0;
}

.inspector-facts div {
  display: grid;
  gap: 2px;
}

.inspector-facts dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.inspector-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.sensitive-text {
  color: var(--danger);
  font-weight: 800;
}

.public-text {
  color: #176f5f;
  font-weight: 800;
}

.inspector-value-block,
.inspector-activity-block {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.inspector-value-heading {
  align-items: center;
  background: #f5f7f8;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  font-size: 12px;
  font-weight: 800;
  justify-content: space-between;
  padding: 7px 9px;
  text-transform: uppercase;
}

.inspector-activity-summary {
  background: #f5f7f8;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  list-style-position: inside;
  padding: 7px 9px;
  text-transform: uppercase;
}

.inspector-activity-block[open] .inspector-activity-summary {
  border-bottom: 1px solid var(--line);
}

.inspector-value {
  display: block;
  max-height: 220px;
  min-height: 76px;
  overflow: auto;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

.inspector-activity-list {
  display: grid;
}

.inspector-activity-item {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 4px;
  padding: 10px;
}

.inspector-activity-item:last-child {
  border-bottom: 0;
}

.inspector-activity-heading {
  align-items: baseline;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.inspector-activity-heading strong,
.inspector-activity-heading span,
.inspector-activity-item p,
.inspector-activity-item code {
  overflow-wrap: anywhere;
}

.inspector-activity-heading span,
.inspector-activity-item p {
  color: var(--muted);
  font-size: 12px;
}

.inspector-activity-item p {
  margin: 0;
}

.inspector-activity-item code {
  color: var(--accent-dark);
  font-size: 12px;
}

.inspector-history-value {
  background: #f7f9fa;
  border: 1px solid var(--line);
  border-radius: 4px;
  display: block;
  max-height: 120px;
  overflow: auto;
  padding: 7px;
  white-space: pre-wrap;
}

.inspector-history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inspector-activity-empty {
  color: var(--muted);
  margin: 0;
  padding: 10px;
}

.inspector-actions,
.change-cart-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inspector-actions button[hidden],
.change-cart-actions [hidden] {
  display: none;
}

.inspector-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.change-cart-actions {
  border-top: 1px solid var(--line);
  display: grid;
  padding: 12px 13px;
}

.change-cart-buttons {
  display: flex;
  gap: 8px;
}

.change-cart-buttons .primary-button {
  flex: 1;
}

.cart-discard {
  color: var(--danger);
  justify-self: start;
}

.cart-diff {
  display: grid;
  gap: 4px 8px;
  grid-template-columns: auto minmax(0, 1fr);
  margin: 6px 0 0;
}

.cart-diff dt {
  align-self: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.cart-diff dd {
  margin: 0;
  min-width: 0;
}

.cart-change.is-production {
  border-left: 3px solid #e6b0aa;
}

.change-cart-actions form {
  margin: 0;
}

.apply-context-form {
  display: grid;
  gap: 8px;
  width: 100%;
}

.apply-context-form .field-label {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  gap: 4px;
}

.apply-context-form .field-label small {
  font-size: 11px;
}

.apply-context-form input[type="url"],
.apply-context-form input[type="text"] {
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  min-width: 0;
  padding: 7px 8px;
  width: 100%;
}

.apply-status {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 13px;
  gap: 7px;
  margin: 0;
}

.apply-status[hidden] {
  display: none;
}

.apply-status::before {
  animation: apply-status-spin 700ms linear infinite;
  border: 2px solid #b7c3c5;
  border-right-color: var(--accent);
  border-radius: 50%;
  content: "";
  height: 13px;
  width: 13px;
}

.apply-context-form .primary-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

@keyframes apply-status-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .apply-status::before {
    animation: none;
  }
}

.cart-list {
  max-height: 420px;
  overflow: auto;
}

.cart-change {
  border-bottom: 1px solid var(--line);
  padding: 11px 13px;
}

.cart-change:last-child {
  border-bottom: 0;
}

.cart-change-heading {
  align-items: start;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.cart-change-heading strong,
.cart-change-heading span {
  display: block;
  overflow-wrap: anywhere;
}

.cart-change-heading span,
.cart-change p {
  color: var(--muted);
  font-size: 12px;
}

.cart-change p {
  margin: 8px 0;
}

.change-cart .production-warning {
  margin: 12px 13px 0;
}

@media (max-width: 980px) {
  .matrix-shell {
    grid-template-columns: 1fr;
  }

  .matrix-sidebar {
    height: auto;
    min-height: auto;
    position: static;
  }

  .matrix-frame {
    max-height: none;
  }
}

/* Landing page (logged-out root) */
.landing {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.landing-nav {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1080px;
  padding: 18px 24px;
  width: 100%;
}

.landing-nav-brand {
  align-items: center;
  display: flex;
  font-weight: 700;
  gap: 9px;
}

.landing-nav-logo {
  height: 26px;
  object-fit: contain;
  width: 26px;
}

.landing-nav-links {
  display: flex;
  gap: 18px;
}

.landing-nav-link {
  color: var(--muted);
  text-decoration: none;
}

.landing-nav-link:hover {
  color: var(--ink);
}

.landing-main {
  flex: 1;
  margin: 0 auto;
  max-width: 1080px;
  padding: 8px 24px 48px;
  width: 100%;
}

.landing-hero {
  margin: 0 auto;
  max-width: 680px;
  padding: 40px 0 28px;
  text-align: center;
}

.landing-hero-logo {
  height: auto;
  max-width: 320px;
  width: 60%;
}

.landing-eyebrow {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 1px;
  margin: 18px 0 6px;
  text-transform: uppercase;
}

.landing-title {
  font-size: 34px;
  line-height: 1.1;
  margin: 0 0 14px;
}

.landing-lede {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
  margin: 0 auto 22px;
  max-width: 600px;
}

.landing-cta {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: center;
}

.landing-signin {
  align-items: center;
  display: inline-flex;
  min-height: 40px;
  padding: 0 18px;
  text-decoration: none;
}

.landing-arch-link {
  color: var(--accent-dark);
  font-weight: 600;
  text-decoration: none;
}

.landing-arch-link:hover {
  text-decoration: underline;
}

.landing-overview {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  margin: 8px auto 0;
  max-width: 720px;
  padding: 26px 0 6px;
  text-align: center;
}

.landing-features {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, 1fr);
  margin: 24px 0 0;
}

.landing-feature {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
}

.landing-feature h2 {
  font-size: 15px;
  margin: 0 0 6px;
}

.landing-feature p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}

.landing-feature code,
.landing-lede code {
  background: #eef1f4;
  border-radius: 4px;
  font-size: 0.92em;
  padding: 1px 5px;
}

.landing-footer {
  align-items: center;
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  font-size: 13px;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1080px;
  padding: 18px 24px;
  width: 100%;
}

/* Logged-in empty state (no apps) */
.empty-shell {
  min-height: 60vh;
}

.empty-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 48px auto 0;
  max-width: 520px;
  padding: 32px;
  text-align: center;
}

.empty-panel h1 {
  font-size: 20px;
  margin: 0 0 8px;
}

.empty-panel p {
  color: var(--muted);
  margin: 0 0 18px;
}

@media (max-width: 860px) {
  .landing-features {
    grid-template-columns: 1fr;
  }

  .access-grant-form {
    grid-template-columns: 1fr;
  }
}

/* Matrix key search + pagination toolbar */
.matrix-toolbar {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 12px 12px 0;
}

.matrix-search {
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  max-width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  width: 300px;
}

.matrix-search:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.matrix-toolbar-right {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: 16px;
}

.matrix-page-size {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  gap: 6px;
  white-space: nowrap;
}

.matrix-page-size select {
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  color: var(--ink);
  min-height: 30px;
  padding: 4px 6px;
}

.matrix-pagination {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.matrix-pagination[hidden] {
  display: none;
}

.matrix-page-info {
  color: var(--muted);
  font-size: 12px;
}

.pager-button {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  font-size: 15px;
  justify-content: center;
  line-height: 1;
  min-height: 30px;
  min-width: 30px;
}

.pager-button:hover:not(:disabled) {
  border-color: #9fb4b1;
}

.pager-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.matrix-empty-filter {
  background: var(--warn-bg);
  border: 1px solid #ead38d;
  border-radius: 4px;
  color: var(--ink);
  margin: 12px;
  padding: 10px 12px;
}

.matrix-empty-filter[hidden] {
  display: none;
}

/* Audit evidence and supplementary activity marks. */
/* Audit: presets first, summary tiles, compact chart, one-line event rows. */
.audit-shell h2 { font-size: 15px; margin: 0 0 10px; }
.audit-shell a { color: var(--accent-dark); }
.audit-shell :focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.audit-filters { display: grid; gap: 8px; }
.audit-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.audit-preset { padding: 6px 12px; border: 1px solid var(--line-dark); border-radius: 999px; background: var(--panel); color: var(--ink) !important; text-decoration: none; }
.audit-preset:hover { border-color: var(--accent); }
.audit-preset[aria-current="true"] { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff !important; font-weight: 600; }
.audit-more summary { cursor: pointer; color: var(--muted); padding: 4px 0; }
.audit-more[open] { padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.audit-filter-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 10px; }
.audit-filter-grid label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.audit-filter-grid input, .audit-filter-grid select { width: 100%; min-width: 0; padding: 7px 8px; border: 1px solid var(--line-dark); border-radius: 4px; background: #fff; color: var(--ink); font: inherit; }
.audit-filter-actions { display: flex; gap: 16px; align-items: center; margin-top: 12px; }
.audit-overview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 18px 0; }
.audit-stat { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); text-decoration: none; }
.audit-stat strong { font-size: 24px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.audit-stat span { color: var(--muted); }
a.audit-stat:hover { border-color: var(--accent); }
.audit-attention-link.has-attention { border-color: #e6b0aa; background: #fdf3f1; }
.audit-attention-link.has-attention strong { color: var(--danger); }
.audit-section { padding: 16px 0; }
.audit-zero, .audit-muted { color: var(--muted); }
.audit-zero { padding: 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.audit-daily { display: flex; gap: 2px; align-items: flex-end; padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.audit-day { display: flex; flex: 1 1 0; min-width: 6px; flex-direction: column; align-items: center; gap: 3px; text-decoration: none; border-radius: 3px; }
.audit-day:hover { background: #edf7f8; }
.audit-bar-track { display: flex; align-items: flex-end; width: 70%; height: 64px; }
.audit-bar { display: block; width: 100%; min-height: 1px; border-radius: 2px 2px 0 0; background: var(--accent); }
.audit-day-mark { width: 5px; height: 5px; border-radius: 999px; }
.audit-day-mark.audit-failure { background: var(--danger); }
.audit-day time { color: var(--muted); font-size: 10px; white-space: nowrap; }
.audit-deliveries { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.audit-deliveries li + li { border-top: 1px solid var(--line); }
.audit-deliveries a { display: flex; justify-content: space-between; gap: 20px; padding: 10px 14px; text-decoration: none; color: var(--ink) !important; }
.audit-table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.audit-table { width: 100%; min-width: 760px; border-collapse: collapse; text-align: left; }
.audit-table caption { text-align: left; padding: 10px 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.audit-table th { padding: 10px 12px; color: var(--muted); font-size: 12px; font-weight: 600; border-bottom: 1px solid var(--line); }
.audit-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.audit-table tbody tr:last-child td { border-bottom: 0; }
.audit-table td:first-child { white-space: nowrap; }
.audit-table small { display: block; margin-top: 3px; color: var(--muted); }
.audit-sensitive { padding: 1px 6px; border-radius: 999px; background: #f1ecf9; color: #5b3e8a; font-size: 11px; }
.audit-details { margin-top: 2px; }
.audit-details[open] { min-width: 220px; }
.audit-details summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.audit-details dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 6px 0 0; font-size: 12px; }
.audit-details dt { color: var(--muted); }
.audit-details dd { margin: 0; }
.audit-outcome { white-space: nowrap; }
.audit-failure { color: var(--danger); font-weight: 600; }
.audit-pagination { display: flex; gap: 24px; justify-content: flex-end; margin-top: 12px; }
@media (max-width: 760px) {
  .audit-filter-grid, .audit-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .audit-deliveries a { flex-direction: column; gap: 4px; }
}
@media print {
  .audit-filters, .audit-pagination, .audit-details summary { display: none; }
  .audit-details dl { display: grid; }
  .audit-table-scroll { overflow: visible; border: 0; }
  .audit-table { min-width: 0; font-size: 9px; }
  .audit-table th, .audit-table td { padding: 5px; }
  .audit-table tr { break-inside: avoid; }
}

/* Global admin console: the workspace sidebar with admin navigation. */
.sidebar-nav-link { gap: 10px; justify-content: flex-start; }
.sidebar-nav-link svg { flex-shrink: 0; height: 17px; width: 17px; color: #aab3bc; }
.sidebar-nav-link[aria-current="page"] { background: #333b44; font-weight: 700; }
.sidebar-nav-link[aria-current="page"] svg { color: #8fc6be; }
.admin-topbar h1 { font-size: 22px; }
.admin-description { color: var(--muted); margin: 4px 0 0; }
.admin-content { max-width: 1120px; min-width: 0; padding: 24px 18px 48px; }
.admin-content:focus { outline: 0; }
.admin-content > .access-shell, .admin-content > .audit-shell { max-width: none; margin: 0; padding: 0; }
.admin-shell :focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.admin-skip-link { position: absolute; left: -10000px; }
.admin-skip-link:focus { left: 8px; top: 8px; z-index: 30; padding: 8px 10px; background: #fff; color: var(--ink); border-radius: 4px; }
@media print {
  .admin-shell { display: block; }
  .admin-shell .matrix-sidebar { display: none; }
  .admin-content { padding: 0; }
}
.admin-content .access-invitation-form > .access-field { width: min(calc(100% - 30px), 420px); }
@media (max-width: 600px) {
  .admin-content .pending-grant-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-content .pending-grant-row > button { justify-self: start; }
  .admin-content .access-field { min-width: 0; }
  .admin-content .machine-credential-form { grid-template-columns: 1fr; }
  .admin-content .access-grant-command, .admin-content .machine-credential-command { flex-wrap: wrap; }
}

/* People page: one card per person, invitation, or team, with access chips. */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.people-filter input { width: min(360px, 100%); padding: 8px 10px; border: 1px solid var(--line-dark); border-radius: 4px; background: var(--panel); }
.people-list { list-style: none; margin: 12px 0 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.person-card { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 14px; }
.person-card + .person-card { border-top: 1px solid var(--line); }
.person-card[hidden] { display: none; }
.avatar-invitation, .avatar-team, .avatar-unresolved { background: #e3e8ec; color: #4b5560; font-weight: 600; }
.person-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; min-height: 34px; align-content: center; }
.person-heading strong { font-size: 14px; }
.person-meta { color: var(--muted); }
.person-actions { display: flex; align-items: center; min-height: 34px; }
.person-actions form { margin: 0; }
.access-chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 6px 0 0; padding: 0; }
.access-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 9px; border: 1px solid var(--line); border-radius: 999px; background: #f6f8f9; }
.access-chip strong { font-weight: 650; }
.access-chip span { color: #4b5560; }
.access-chip:not(:has(form)) { padding-right: 9px; }
.access-chip.is-production { border-color: #e6b0aa; background: #fdf3f1; }
.access-chip form { margin: 0; }
.access-chip-remove { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; }
.access-chip-remove:hover { background: #f9e1de; color: var(--danger); }
.past-invitations { margin-top: 16px; color: var(--muted); }
.past-invitations summary { cursor: pointer; padding: 6px 0; }
.past-invitations ul { list-style: none; margin: 4px 0 0; padding: 0; }
.past-invitations li { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 6px 0; border-top: 1px solid var(--line); }
.past-invitations strong { color: var(--ink); font-weight: 600; }
.add-access-modal { width: min(620px, 94vw); }
.add-access-modal select, .add-access-modal input[type="email"] { width: 100%; padding: 8px; border: 1px solid var(--line-dark); border-radius: 4px; background: #fff; font: inherit; }
.add-access-modal .email-field { display: grid; gap: 4px; }
.add-access-modal .email-field[hidden] { display: none; }
.field-help { margin: 0; color: var(--muted); font-size: 12px; }
.access-rows { display: grid; gap: 10px; }
.access-row { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) 28px; gap: 4px 8px; align-items: end; padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: #f8f9fa; }
.access-row-remove { width: 28px; height: 34px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; }
.access-row-remove:hover:not(:disabled) { background: #f9e1de; color: var(--danger); }
.access-row-remove:disabled { visibility: hidden; }
.access-row-description { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 12px; }
.add-access-modal .link-button { justify-self: start; color: var(--accent-dark); font-weight: 600; }
.add-access-modal footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.add-access-modal footer .apply-status { margin: 0 auto 0 0; }
@media (max-width: 600px) {
  .person-card { grid-template-columns: 34px minmax(0, 1fr); }
  .person-actions { grid-column: 2; }
  .access-row { grid-template-columns: minmax(0, 1fr) 28px; }
}
.person-add-access { opacity: 0; color: var(--accent-dark); font-weight: 600; }
.person-card:hover .person-add-access, .person-add-access:focus-visible { opacity: 1; }
@media (hover: none) { .person-add-access { opacity: 1; } }

/* Machine credentials: status first, details second. */
.credential-list { list-style: none; margin: 0; padding: 0; }
.credential-row { display: grid; grid-template-columns: 128px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 15px; border-top: 1px solid var(--line); }
.credential-list > .credential-row:first-child { border-top: 0; }
.credential-row form { margin: 0; }
.credential-body { display: grid; gap: 2px; min-width: 0; }
.credential-body strong { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; overflow-wrap: anywhere; }
.credential-scope { color: var(--ink); }
.credential-body small { color: var(--muted); font-size: 12px; }
.status-badge { justify-self: start; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-active { background: #e3f4ef; color: #1f6b52; }
.status-expiring { background: var(--warn-bg); color: #7a5a00; }
.status-expired, .status-revoked { background: #eceff2; color: #5b6570; }
.credential-history { border-top: 1px solid var(--line); }
.credential-history summary { cursor: pointer; padding: 10px 15px; color: var(--muted); }
.credential-history .credential-row:first-child { border-top: 1px solid var(--line); }
@media (max-width: 600px) {
  .credential-row { grid-template-columns: minmax(0, 1fr) auto; }
  .credential-row .status-badge { grid-column: 1 / -1; }
}
a.primary-button, a.secondary-button { display: inline-flex; align-items: center; text-decoration: none; color: inherit; }
a.primary-button { color: #fff; }
.environment-add-form .settings-checkbox { grid-column: 1 / -1; }
.settings-danger-zone .danger-button { white-space: nowrap; }

/* Workspace: the matrix narrows beside an open slide-over panel. */
@media (min-width: 900px) {
  .matrix-shell.panel-open .matrix-workspace { margin-right: 360px; }
}
.inspector-history-heading { margin: 10px 12px 4px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.history-current { padding: 1px 7px; border-radius: 999px; background: #e3f4ef; color: #1f6b52; font-size: 11px; font-weight: 600; }
.inspector-history-actions { display: flex; gap: 6px; }
