:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-subtle: #fafbfe;
  --line: #e5e7ef;
  --line-strong: #d6d9e6;
  --text: #181b25;
  --muted: #697085;
  --accent: #635bff;
  --accent-soft: #f2f1ff;
  --good-bg: #edf9f1;
  --good-text: #1c7d3c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Avenir Next", "Segoe UI", sans-serif;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-shell[hidden] {
  display: none !important;
}

#auth-root {
  width: min(460px, 100%);
}

.auth-actions {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 10px 20px rgba(16, 24, 40, 0.06);
}

.auth-actions h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -0.02em;
}

.auth-actions p {
  margin: 8px 0 0;
  color: var(--muted);
}

.auth-actions__buttons {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

#app-shell {
  min-height: 100vh;
}

.topbar {
  height: 58px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
}

.topbar__left,
.topbar__right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace-icon {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: #4ea6d9;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.sep {
  color: #c2c8d8;
}

.env-pill {
  background: #fff6ea;
  color: #a15d12;
  border: 1px solid #f2d0a3;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
}

.tabs {
  height: 52px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: end;
  gap: 18px;
  padding: 0 22px;
}

.tabs a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  padding-bottom: 11px;
  border-bottom: 2px solid transparent;
}

.tabs a.active {
  color: var(--text);
  border-bottom-color: var(--text);
  font-weight: 600;
}

.content {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 18px 40px;
}

.view[hidden] {
  display: none !important;
}

.heading-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.heading-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.heading-row h1 {
  margin: 0;
  font-size: 38px;
  letter-spacing: -0.03em;
}

.heading-row p {
  margin: 8px 0 0;
  color: var(--muted);
}

.filters-row {
  margin-top: 20px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.filters-row input {
  min-width: 280px;
}

.table-card,
.form-card {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.table-head,
.table-row {
  display: grid;
  grid-template-columns: 2fr 1.3fr 1.2fr 1.4fr 1fr;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
}

.table-head--integrations,
.table-row--integrations {
  grid-template-columns: 2fr 1.5fr 1fr 1fr;
}

.table-head {
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.table-row {
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.table-row:last-child {
  border-bottom: 0;
}

.table-cell__title {
  font-weight: 600;
  color: var(--text);
}

.table-cell__sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.table-empty {
  padding: 30px 18px;
  text-align: center;
  color: var(--muted);
}

.table-actions {
  display: flex;
  gap: 6px;
}

.form-card {
  padding: 18px;
}

.form-card h2 {
  margin: 0;
  font-size: 22px;
}

.form-card p {
  margin: 8px 0 0;
  color: var(--muted);
}

form {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.watchdog-type-field {
  grid-column: 1 / -1;
  border: 0;
  padding: 0;
  margin: 0;
  min-inline-size: 0;
}

.watchdog-type-field legend {
  padding: 0;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.watchdog-type-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.watchdog-type-option {
  display: block;
  margin: 0;
  cursor: pointer;
}

.watchdog-type-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.watchdog-type-option__body {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-subtle);
  padding: 11px 12px;
}

.watchdog-type-option input[type="radio"]:checked + .watchdog-type-option__body {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 91, 255, 0.14);
  background: #fff;
}

.watchdog-type-option__title {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.watchdog-type-option__copy {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

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

.conditional-grid[hidden] {
  display: none !important;
}

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

label.full-width {
  grid-column: 1 / -1;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface-subtle);
  color: var(--text);
  padding: 9px 11px;
}

input:focus,
select:focus {
  outline: 2px solid rgba(99, 91, 255, 0.16);
  border-color: var(--accent);
}

.primary-btn,
.ghost-btn,
.table-actions button {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
}

.ghost-btn,
.table-actions button {
  background: #fff;
  color: #3b4256;
  border-color: var(--line-strong);
}

.table-actions button {
  padding: 5px 9px;
  font-size: 12px;
}

#create-watchdog-form .primary-btn,
#add-integration-form .primary-btn {
  grid-column: 1 / -1;
  justify-self: start;
}

#create-result,
#integration-result {
  min-height: 18px;
  margin: 14px 0 0;
  color: var(--muted);
  white-space: pre-wrap;
}

#integration-setup-output,
#aws-setup-guide {
  min-height: 18px;
  margin: 14px 0 0;
  color: var(--muted);
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.45;
}

.integration-options {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-subtle);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.integration-choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.integration-choice input[type="checkbox"] {
  margin-top: 3px;
}

.integration-choice__meta {
  display: grid;
  gap: 3px;
}

.integration-choice__name {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
}

.integration-choice__detail {
  font-size: 12px;
  color: var(--muted);
}

.integration-choice__empty {
  font-size: 13px;
  color: var(--muted);
}

.inline-input-row {
  display: flex;
  gap: 8px;
}

.inline-input-row input {
  flex: 1;
}

.inline-button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-button-row .primary-btn,
.inline-button-row .ghost-btn {
  white-space: nowrap;
}

.integration-note {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.permissions-fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin: 0;
  display: grid;
  gap: 6px;
}

.permissions-fieldset legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.permission-option {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 500;
}

.managed-action {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--accent-soft);
  color: #3f3a92;
  padding: 10px;
  font-size: 13px;
  font-weight: 500;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  background: var(--good-bg);
  color: var(--good-text);
  border: 1px solid #b8e6c7;
}

.capability-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.capability-pill {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--muted);
  background: #fff;
}

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

@media (max-width: 920px) {
  .topbar {
    height: auto;
    padding: 10px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .tabs {
    overflow-x: auto;
    white-space: nowrap;
  }

  .heading-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .heading-actions {
    width: 100%;
  }

  .table-head {
    display: none;
  }

  .table-row,
  .table-row--integrations {
    grid-template-columns: 1fr;
    gap: 6px;
  }

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

  .conditional-grid {
    grid-template-columns: 1fr;
  }

  .watchdog-type-grid {
    grid-template-columns: 1fr;
  }
}
