/* Wisewell Env Manager — design system
   Tokens → primitives → page patterns. Light by default, dark via tokens.
   Works with JS off; `html.js` unlocks the progressive enhancements. */

/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --paper: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #f0efea;
  --surface-3: #e6e5df;
  --ink: #15171b;
  --ink-2: #555b66;
  --ink-3: #868c97;
  --line: rgba(21, 23, 27, 0.09);
  --line-strong: rgba(21, 23, 27, 0.18);
  --accent: #2d6ea0;
  --accent-hover: #255d87;
  --accent-soft: rgba(45, 110, 160, 0.1);
  --on-accent: #ffffff;
  --ok: #2f8a56;
  --ok-soft: rgba(47, 138, 86, 0.12);
  --warn: #9a6400;
  --warn-soft: rgba(212, 168, 67, 0.2);
  --danger: #c0392b;
  --danger-hover: #a93224;
  --danger-soft: rgba(192, 57, 43, 0.1);
  --purple: #6f4bb3;
  --purple-soft: rgba(111, 75, 179, 0.12);
  --focus: 0 0 0 3px rgba(45, 110, 160, 0.32);
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --shadow-pop: 0 14px 36px -14px rgba(21, 23, 27, 0.3), 0 2px 6px rgba(21, 23, 27, 0.08);
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sidebar-w: 236px;
  --dur: 160ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --deep-1: #0e2238;
  --deep-2: #14406a;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0f1115;
  --surface: #161a20;
  --surface-2: #1c2129;
  --surface-3: #252b35;
  --ink: #e9eaee;
  --ink-2: #a4aab5;
  --ink-3: #727987;
  --line: rgba(233, 234, 238, 0.08);
  --line-strong: rgba(233, 234, 238, 0.16);
  --accent: #5aa6e0;
  --accent-hover: #74b5e8;
  --accent-soft: rgba(90, 166, 224, 0.14);
  --on-accent: #0b1118;
  --ok: #4fbf7d;
  --ok-soft: rgba(79, 191, 125, 0.14);
  --warn: #e0b352;
  --warn-soft: rgba(224, 179, 82, 0.16);
  --danger: #ef6b5e;
  --danger-hover: #f4857a;
  --danger-soft: rgba(239, 107, 94, 0.14);
  --purple: #b094ea;
  --purple-soft: rgba(176, 148, 234, 0.14);
  --focus: 0 0 0 3px rgba(90, 166, 224, 0.4);
  --shadow-pop: 0 18px 44px -14px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0f1115;
    --surface: #161a20;
    --surface-2: #1c2129;
    --surface-3: #252b35;
    --ink: #e9eaee;
    --ink-2: #a4aab5;
    --ink-3: #727987;
    --line: rgba(233, 234, 238, 0.08);
    --line-strong: rgba(233, 234, 238, 0.16);
    --accent: #5aa6e0;
    --accent-hover: #74b5e8;
    --accent-soft: rgba(90, 166, 224, 0.14);
    --on-accent: #0b1118;
    --ok: #4fbf7d;
    --ok-soft: rgba(79, 191, 125, 0.14);
    --warn: #e0b352;
    --warn-soft: rgba(224, 179, 82, 0.16);
    --danger: #ef6b5e;
    --danger-hover: #f4857a;
    --danger-soft: rgba(239, 107, 94, 0.14);
    --purple: #b094ea;
    --purple-soft: rgba(176, 148, 234, 0.14);
    --focus: 0 0 0 3px rgba(90, 166, 224, 0.4);
    --shadow-pop: 0 18px 44px -14px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.35);
  }
}

/* ---------- base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a {
  color: var(--accent);
}
h1,
h2,
h3 {
  font-weight: 600;
  letter-spacing: -0.012em;
  line-height: 1.25;
  margin: 0;
}
p {
  margin: 0 0 1em;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
[hidden] {
  display: none !important;
}
:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
::selection {
  background: var(--accent-soft);
}
html:not(.js) .js-only {
  display: none !important;
}
html.js .js-hidden {
  display: none !important;
}
html:not(.js) .secret-block.is-masked .pre {
  color: inherit;
  text-shadow: none;
  user-select: auto;
}
.i {
  width: 16px;
  height: 16px;
  display: inline-block;
  vertical-align: -3px;
  flex: none;
}
.mono {
  font-family: var(--mono);
  font-size: 12.5px;
}
.muted {
  color: var(--ink-3);
}
.small {
  font-size: 12.5px;
}
.nowrap {
  white-space: nowrap;
}
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.skip {
  position: absolute;
  left: -999px;
  top: 10px;
  z-index: 100;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
  text-decoration: none;
}
.skip:focus {
  left: 10px;
}

/* ---------- shell ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
body.no-shell .shell {
  grid-template-columns: minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 14px 18px;
  border-right: 1px solid var(--line);
  background: var(--paper);
}
.brand {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 4px 10px 18px;
  color: var(--ink);
  text-decoration: none;
  border-radius: var(--r-sm);
}
.brand-logo {
  width: 126px;
  height: 34px;
  display: block;
  color: var(--ink);
}
.brand-app {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  padding-left: 1px;
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-group {
  margin: 16px 10px 4px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-3);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 500;
  transition:
    background var(--dur) var(--ease),
    color var(--dur) var(--ease);
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.nav-item.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}
.nav-item .i {
  color: var(--ink-3);
}
.nav-item.is-active .i {
  color: var(--accent);
}
.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
  min-width: 0;
}
.avatar {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 12px;
}
.user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}
.user-email {
  font-size: 12.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-role {
  font-size: 11.5px;
  color: var(--ink-3);
}
.foot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.theme-toggle .i-sun {
  display: none;
}
:root[data-theme="dark"] .theme-toggle .i-sun {
  display: inline-block;
}
:root[data-theme="dark"] .theme-toggle .i-moon {
  display: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun {
    display: inline-block;
  }
  :root:not([data-theme="light"]) .theme-toggle .i-moon {
    display: none;
  }
}

.content {
  min-width: 0;
  width: 100%;
  max-width: 1240px;
  padding: 30px 36px 72px;
}
body.no-shell .content {
  max-width: none;
  padding: 0;
}

/* ---------- page header ---------- */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}
.crumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.crumbs a {
  color: var(--ink-2);
  text-decoration: none;
}
.crumbs a:hover {
  color: var(--ink);
  text-decoration: underline;
}
.crumbs .i {
  width: 12px;
  height: 12px;
  vertical-align: -2px;
}
.page-title {
  font-size: 22px;
  letter-spacing: -0.018em;
  overflow-wrap: anywhere;
}
.page-meta {
  margin: 10px 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  color: var(--ink-2);
  font-size: 13px;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding-top: 22px;
}
.page-head.is-plain .page-actions {
  padding-top: 0;
}

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: 20px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.card-title {
  font-size: 14px;
}
.card-desc {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--ink-2);
}
.card-body {
  padding: 18px;
}
.card-foot {
  padding: 10px 18px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-3);
}
.card.is-danger {
  border-color: rgba(192, 57, 43, 0.35);
}
.card.is-danger .card-head {
  border-bottom-color: rgba(192, 57, 43, 0.2);
}
.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

/* ---------- stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  margin-bottom: 20px;
}
.stat {
  background: var(--surface);
  padding: 12px 16px;
}
.stat-label {
  font-size: 12px;
  color: var(--ink-3);
}
.stat-value {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}
.stat-ok .stat-value {
  color: var(--ok);
}
.stat-warn .stat-value {
  color: var(--warn);
}
.stat-danger .stat-value {
  color: var(--danger);
}

/* ---------- tables ---------- */
.table-wrap {
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table caption {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table th:first-child,
.table td:first-child {
  padding-left: 18px;
}
.table th:last-child,
.table td:last-child {
  padding-right: 18px;
}
.table tbody tr:last-child td {
  border-bottom: 0;
}
.table tbody tr:hover {
  background: var(--surface-2);
}
.table .actions {
  text-align: right;
  white-space: nowrap;
}
.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  opacity: 0.6;
  transition: opacity var(--dur) var(--ease);
}
tr:hover .row-actions,
tr:focus-within .row-actions {
  opacity: 1;
}
.cell-title {
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
}
.cell-title:hover {
  text-decoration: underline;
}
.cell-sub {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
}
.table tr.sync-error td:first-child {
  box-shadow: inset 3px 0 0 var(--danger);
}
.table tr.sync-pending td:first-child {
  box-shadow: inset 3px 0 0 var(--warn);
}
.table tr.is-dirty {
  background: var(--accent-soft);
}
.table tr.is-dirty:hover {
  background: var(--accent-soft);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-weight: 500;
  font-size: 13.5px;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  transition:
    background var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    color var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
.btn:active {
  transform: translateY(1px);
}
.btn .i {
  width: 15px;
  height: 15px;
  vertical-align: 0;
}
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
}
.btn-secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
}
.btn-secondary:hover {
  background: var(--surface-2);
}
.btn-ghost {
  background: transparent;
  color: var(--ink-2);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: var(--danger-hover);
}
.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
}
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: default;
  transform: none;
}
.btn.is-loading {
  color: transparent !important;
  pointer-events: none;
}
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--ink-3);
  border-top-color: transparent;
  animation: spin 0.7s linear infinite;
}
.btn-primary.is-loading::after,
.btn-danger.is-loading::after {
  border-color: rgba(255, 255, 255, 0.7);
  border-top-color: transparent;
}
.btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-3);
  display: inline-grid;
  place-items: center;
  transition:
    background var(--dur) var(--ease),
    color var(--dur) var(--ease);
}
.btn-icon:hover {
  background: var(--surface-3);
  color: var(--ink);
}
.btn-icon.is-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
.btn-icon .i {
  width: 15px;
  height: 15px;
  vertical-align: 0;
}
.btn-icon[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}
.btn-icon.is-copied,
.key-btn.is-copied {
  color: var(--ok);
}
.btn-icon .i-check,
[data-action="reveal"] .i-eye-off {
  display: none;
}
.btn-icon.is-copied .i-copy {
  display: none;
}
.btn-icon.is-copied .i-check {
  display: inline-block;
}
[data-action="reveal"][aria-pressed="true"] .i-eye {
  display: none;
}
[data-action="reveal"][aria-pressed="true"] .i-eye-off {
  display: inline-block;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- forms ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
}
.hint {
  font-size: 12px;
  color: var(--ink-3);
  margin: 0;
}
.hint.is-error {
  color: var(--danger);
}
.input,
.select,
.textarea {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  transition:
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}
.textarea {
  height: auto;
  min-height: 80px;
  padding: 8px 10px;
  resize: vertical;
  line-height: 1.45;
}
.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--focus);
}
.input::placeholder,
.textarea::placeholder {
  color: var(--ink-3);
}
.input.mono,
.textarea.mono {
  font-family: var(--mono);
  font-size: 12.5px;
}
.input.is-invalid {
  border-color: var(--danger);
}
.select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23868c97' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 14px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px 16px;
}
.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
}
.inline-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.inline-form .field {
  flex: 1 1 200px;
}
.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-2);
  position: relative;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-track {
  flex: none;
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  position: relative;
  transition: background var(--dur) var(--ease);
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform var(--dur) var(--ease);
}
.switch input:checked + .switch-track {
  background: var(--accent);
  border-color: var(--accent);
}
.switch input:checked + .switch-track::after {
  transform: translateX(14px);
}
.switch input:focus-visible + .switch-track {
  box-shadow: var(--focus);
}
.switch input:disabled + .switch-track {
  opacity: 0.5;
}
.switch.is-compact {
  gap: 0;
}

/* ---------- badges, chips, kbd ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--surface-3);
  color: var(--ink-2);
  white-space: nowrap;
  vertical-align: middle;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.badge-accent {
  background: var(--accent-soft);
  color: var(--accent);
}
.badge.is-plain::before {
  display: none;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
  vertical-align: middle;
}
a.chip:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}
.chip .i {
  width: 12px;
  height: 12px;
  vertical-align: 0;
}
.chip-row {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}
.chip-toggle {
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip-toggle[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.3;
  color: var(--ink-2);
  background: var(--surface);
}
.act {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.act-env {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
}
.act-admin {
  color: var(--purple);
  background: var(--purple-soft);
  border-color: transparent;
}
.act-sync {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: transparent;
}
.act-auth {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: transparent;
}
.actor-system {
  color: var(--ink-3);
  font-style: italic;
}

/* ---------- toolbar + search ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.search {
  position: relative;
  flex: 1 1 220px;
  max-width: 380px;
}
.search > .i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--ink-3);
  pointer-events: none;
}
.search .input {
  padding-left: 30px;
  padding-right: 36px;
  height: 32px;
}
.search .kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
.toolbar-count {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* ---------- secrets table ---------- */
.key-btn {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 4px 6px;
  margin-left: -6px;
  border-radius: 4px;
  text-align: left;
  position: relative;
  white-space: nowrap;
}
.key-btn:hover {
  background: var(--surface-3);
}
.key-btn.is-copied::after {
  content: "Copied";
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 8px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  color: var(--ok);
  background: var(--ok-soft);
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}
.secret {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 280px;
}
.secret-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border-color: transparent;
  background: transparent;
  font-family: var(--mono);
  font-size: 12.5px;
}
.secret-input[type="password"] {
  letter-spacing: 0.1em;
}
.secret-input:hover {
  border-color: var(--line);
}
.secret-input:focus-visible,
tr.is-dirty .secret-input {
  border-color: var(--accent);
  background: var(--surface);
}
.secret-input::placeholder {
  color: var(--ink-3);
  letter-spacing: 0;
}
html.js .save-actions {
  display: none;
}
html.js tr.is-dirty .save-actions {
  display: inline-flex;
  gap: 4px;
  margin-left: 4px;
}
.sync-note {
  display: block;
  max-width: 260px;
  font-size: 11.5px;
  color: var(--danger);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 70;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: min(400px, calc(100vw - 32px));
  padding: 12px 12px 12px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
  font-size: 13.5px;
  animation: toast-in 220ms var(--ease);
}
.toast.is-leaving {
  animation: toast-out 180ms var(--ease) forwards;
}
.toast > .i {
  width: 16px;
  height: 16px;
  margin-top: 2px;
}
.toast-ok > .i {
  color: var(--ok);
}
.toast-error > .i {
  color: var(--danger);
}
.toast-text {
  flex: 1;
  overflow-wrap: anywhere;
}
.toast-close {
  width: 24px;
  height: 24px;
  margin: -2px -2px -2px 4px;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(-6px);
  }
}
.alert {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 13px;
  margin-bottom: 16px;
}
.alert .i {
  margin-top: 2px;
}
.alert-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.alert-warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.alert-info {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- dialog ---------- */
.dialog {
  border: 0;
  border-radius: var(--r-lg);
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
  width: min(440px, calc(100vw - 32px));
}
.dialog::backdrop {
  background: rgba(10, 12, 16, 0.5);
  backdrop-filter: blur(2px);
}
.dialog[open] {
  animation: pop-in 180ms var(--ease);
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.dialog-body {
  padding: 22px 22px 18px;
}
.dialog-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--danger-soft);
  color: var(--danger);
  margin-bottom: 12px;
}
.dialog-icon .i {
  width: 18px;
  height: 18px;
  vertical-align: 0;
}
.dialog-title {
  font-size: 16px;
  margin-bottom: 6px;
}
.dialog-text {
  margin: 0;
  color: var(--ink-2);
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ---------- drawer (card without JS, side panel with JS) ---------- */
.drawer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: 20px;
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.drawer-title {
  font-size: 15px;
}
.drawer-body {
  padding: 18px;
}
.drawer-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}
html:not(.js) [data-drawer-close] {
  display: none;
}
html.js .drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(480px, 100vw);
  z-index: 60;
  margin: 0;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  box-shadow: var(--shadow-pop);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  visibility: hidden;
  transition:
    transform 220ms var(--ease),
    visibility 0s linear 220ms;
}
html.js .drawer.is-open {
  transform: none;
  visibility: visible;
  transition:
    transform 220ms var(--ease),
    visibility 0s;
}
html.js .drawer-body {
  flex: 1;
  overflow: auto;
  padding: 20px;
}
html.js .drawer-head,
html.js .drawer-foot {
  padding-left: 20px;
  padding-right: 20px;
}
.drawer-backdrop {
  display: none;
}
html.js .drawer-backdrop {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 59;
  background: rgba(10, 12, 16, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms var(--ease);
}
html.js .drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* ---------- empty state ---------- */
.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--ink-2);
}
.empty .i {
  width: 28px;
  height: 28px;
  color: var(--ink-3);
  margin-bottom: 10px;
}
.empty-title {
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}
.empty p {
  margin: 0 0 14px;
}

/* ---------- environment list (project page) ---------- */
.env-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.env-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}
.env-item:last-child {
  border-bottom: 0;
}
.env-item .i-layers {
  color: var(--ink-3);
}
.env-name {
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
}
.env-name:hover {
  text-decoration: underline;
}
.env-main {
  flex: 1;
  min-width: 0;
}
.env-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ---------- details / code ---------- */
.pre {
  margin: 0;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink);
}
details.meta summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--ink-2);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
details.meta summary::-webkit-details-marker {
  display: none;
}
details.meta summary .i {
  width: 12px;
  height: 12px;
  transition: transform var(--dur) var(--ease);
}
details.meta[open] summary .i {
  transform: rotate(90deg);
}
details.meta[open] summary {
  margin-bottom: 8px;
}
.copy-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.copy-row .pre {
  flex: 1;
  max-height: 110px;
}
.secret-block.is-masked .pre {
  color: transparent;
  text-shadow: 0 0 8px var(--ink-2);
  user-select: none;
}

/* ---------- stepper ---------- */
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: step;
}
.step {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  counter-increment: step;
}
.step:last-child {
  border-bottom: 0;
}
.step::before {
  content: counter(step);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.step.is-done::before {
  content: "\2713";
  background: var(--ok-soft);
  border-color: transparent;
  color: var(--ok);
}
.step-title {
  font-weight: 600;
  margin: 4px 0 4px;
}
.step p {
  margin: 0;
  color: var(--ink-2);
}
.step p + p {
  margin-top: 6px;
}

/* ---------- auth ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
}
.auth-panel {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 10% 0%, rgba(90, 166, 224, 0.28), transparent 60%),
    linear-gradient(165deg, var(--deep-1) 0%, var(--deep-2) 70%, #2d6ea0 140%);
  color: #eaf2fa;
  padding: 44px 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #eaf2fa;
}
.auth-brand .brand-logo {
  width: 132px;
  height: 36px;
  color: #eaf2fa;
}
.auth-brand .brand-app {
  color: rgba(234, 242, 250, 0.7);
  border-left: 1px solid rgba(234, 242, 250, 0.25);
  padding-left: 12px;
  font-size: 13px;
}
.auth-mark {
  width: min(320px, 55%);
  height: auto;
  aspect-ratio: 1;
  color: rgba(234, 242, 250, 0.9);
  align-self: center;
}
.auth-copy h2 {
  font-size: 28px;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
  max-width: 18ch;
  color: #fff;
}
.auth-copy p {
  margin: 0;
  color: rgba(234, 242, 250, 0.72);
  font-size: 15px;
  max-width: 40ch;
}
.auth-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}
.auth-form {
  width: 100%;
  max-width: 360px;
}
.auth-form h1 {
  font-size: 24px;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.auth-sub {
  margin: 0 0 22px;
  color: var(--ink-2);
}
.g-btn {
  display: flex;
  justify-content: center;
  margin: 4px 0 6px;
  min-height: 44px;
}
.auth-alt {
  margin-top: 22px;
}
.auth-alt summary {
  cursor: pointer;
  color: var(--ink-2);
  font-size: 13px;
  list-style: none;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.auth-alt summary::-webkit-details-marker {
  display: none;
}
.auth-alt summary .i {
  width: 12px;
  height: 12px;
  transition: transform var(--dur) var(--ease);
}
.auth-alt[open] summary .i {
  transform: rotate(90deg);
}
.auth-alt[open] summary {
  margin-bottom: 16px;
}
.auth-form .field + .field {
  margin-top: 14px;
}
.auth-form .btn {
  width: 100%;
  margin-top: 18px;
  height: 38px;
}
.auth-foot {
  margin-top: 26px;
  font-size: 12.5px;
  color: var(--ink-3);
}

/* ---------- error page ---------- */
.error-page {
  min-height: 80vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px 20px;
}
.error-code {
  font-family: var(--mono);
  color: var(--ink-3);
  margin: 0 0 8px;
  font-size: 13px;
}
.error-page h1 {
  font-size: 22px;
  margin-bottom: 8px;
}
.error-page p {
  color: var(--ink-2);
  margin: 0 auto 20px;
  max-width: 46ch;
}
.error-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 900px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 10px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 4px 6px;
  }
  .brand-logo {
    width: 96px;
    height: 26px;
  }
  .brand-app {
    padding-left: 10px;
    border-left: 1px solid var(--line-strong);
  }
  .nav {
    flex-direction: row;
    overflow-x: auto;
    flex: 1 1 100%;
    order: 3;
    gap: 4px;
    padding-bottom: 2px;
  }
  .nav-group {
    display: none;
  }
  .nav-item {
    padding: 6px 10px;
    flex: none;
  }
  .sidebar-foot {
    margin: 0 0 0 auto;
    padding: 0;
    border: 0;
    flex-direction: row;
    align-items: center;
    gap: 6px;
  }
  .user-meta {
    display: none;
  }
  .content {
    padding: 20px 16px 48px;
  }
  /* Narrow screens scroll the table sideways instead of crushing cells. */
  .table {
    min-width: 720px;
  }
  .page-head {
    flex-direction: column;
    gap: 12px;
  }
  .page-actions {
    padding-top: 0;
    flex-wrap: wrap;
  }
  html.js .drawer {
    width: 100vw;
    border-left: 0;
  }
}
@media (max-width: 840px) {
  .auth {
    grid-template-columns: 1fr;
  }
  .auth-panel {
    display: none;
  }
}

/* ---------- motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
