:root {
  --bg: #eef2f5;
  --sidebar: #dfe6eb;
  --surface: #f8fafb;
  --surface-2: #ffffff;
  --stroke: #d7e0e6;
  --stroke-strong: #bdc9d2;
  --text: #192126;
  --muted: #65737e;
  --subtle: #83909a;
  --accent: #087f8c;
  --accent-dark: #056672;
  --success: #1f8a5b;
  --warning: #a66605;
  --danger: #b42318;
  --info: #2563a6;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  align-content: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  background: var(--bg);
}

.auth-fallback {
  width: min(460px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--stroke-strong);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  min-height: 34px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.app-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

.user-button {
  min-width: 32px;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--stroke);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #17343a;
  color: #f6fbfc;
  font-weight: 700;
  font-size: 13px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.topbar p,
.panel-head p,
.metric span {
  color: var(--muted);
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav a {
  color: #34444d;
  text-decoration: none;
  padding: 9px 10px;
  border-radius: 7px;
  font-size: 14px;
}

.nav a.active,
.nav a:hover {
  background: #f5f8fa;
  color: var(--text);
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  padding: 10px;
}

.state-dot {
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: var(--subtle);
}

.state-safe {
  background: var(--success);
}

.workspace {
  min-width: 0;
  padding: 22px;
  display: grid;
  gap: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 16px;
}

.connection {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.agent-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  align-items: end;
}

.wide-field {
  grid-column: span 2;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

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

input,
select,
textarea {
  min-height: 34px;
  border: 1px solid var(--stroke-strong);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  padding: 7px 9px;
}

textarea {
  min-width: 100%;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
}

.metric {
  padding: 14px;
  display: grid;
  gap: 6px;
}

.metric strong {
  font-size: 22px;
}

.danger-soft {
  background: #fff7f6;
  border-color: #f3c4bd;
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.75fr);
  gap: 14px;
}

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

.panel {
  padding: 14px;
  min-width: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.panel-head.compact {
  align-items: center;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid var(--stroke);
  vertical-align: top;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  background: #edf7f1;
  color: var(--success);
  font-size: 12px;
}

.status-pill.failed,
.status-pill.error {
  background: #fff0ef;
  color: var(--danger);
}

.status-pill.pending,
.status-pill.running {
  background: #fff6df;
  color: var(--warning);
}

.stack-list {
  display: grid;
  gap: 9px;
}

.stack-item {
  display: grid;
  gap: 4px;
  padding: 9px;
  border: 1px solid var(--stroke);
  border-radius: 7px;
  background: var(--surface-2);
  font-size: 13px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.stack-item span {
  color: var(--muted);
}

.readiness {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.basis-scan-list {
  margin-top: 10px;
}

.secret-list {
  margin-top: 10px;
}

.secret-row {
  border-style: dashed;
}

.secret-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: end;
}

pre {
  margin: 0;
  max-height: 420px;
  overflow: auto;
  padding: 12px;
  background: #142024;
  color: #d9f0f3;
  border-radius: 7px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

dialog {
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 0;
  width: min(560px, calc(100vw - 28px));
}

dialog form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

menu {
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #17262b;
  color: white;
  padding: 10px 12px;
  border-radius: 7px;
  box-shadow: 0 12px 28px rgba(20, 32, 36, 0.18);
  font-size: 13px;
}

.link-button {
  color: var(--accent-dark);
  background: transparent;
  border: 0;
  padding: 0;
  min-height: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: left;
  white-space: normal;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    flex-direction: row;
    align-items: center;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .nav {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
  }

  .sidebar-footer {
    display: none;
  }

  .workspace {
    overflow: hidden;
    padding: 14px;
  }

  .topbar,
  .panel-head {
    flex-direction: column;
  }

  .status-grid,
  .panel-grid {
    grid-template-columns: 1fr;
  }

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

  .wide-field {
    grid-column: auto;
  }

  .secret-controls {
    grid-template-columns: 1fr;
  }

  .panel {
    overflow: hidden;
  }
}
