:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-blue: #f3f7ff;
  --text: #172033;
  --text-soft: #5d687a;
  --text-faint: #7b8799;
  --border: #dce3ed;
  --border-strong: #c7d1df;
  --primary: #1769e0;
  --primary-hover: #0e57c2;
  --primary-soft: #eaf2ff;
  --success: #137a4b;
  --success-soft: #e7f7ef;
  --warning: #9b5c00;
  --warning-soft: #fff5d9;
  --danger: #c83232;
  --danger-hover: #a92222;
  --danger-soft: #fff0f0;
  --shadow-sm: 0 1px 2px rgba(19, 32, 55, 0.06);
  --shadow-md: 0 14px 38px rgba(30, 48, 80, 0.13);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --focus: 0 0 0 3px rgba(23, 105, 224, 0.22);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button,
select {
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

a {
  color: var(--primary);
}

code {
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
  overflow-wrap: anywhere;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--text);
  line-height: 1.25;
  letter-spacing: -0.018em;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  color: #fff;
  background: var(--primary);
  border-radius: var(--radius-sm);
  transform: translateY(-160%);
  transition: transform 0.15s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  place-items: center;
  color: #fff;
  font-size: 19px;
  font-weight: 780;
  line-height: 1;
  background: linear-gradient(145deg, #287df0, #0e54c1);
  border-radius: 10px;
  box-shadow: 0 7px 16px rgba(23, 105, 224, 0.22);
}

.brand > span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.brand strong {
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand small {
  margin-top: 3px;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.2;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 650;
  line-height: 1.25;
  text-decoration: none;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.1s ease;
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

.button-primary {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.button-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.button-secondary {
  color: #2b3b53;
  background: #fff;
  border-color: var(--border-strong);
}

.button-secondary:hover:not(:disabled) {
  background: var(--surface-soft);
  border-color: #aebacb;
}

.button-ghost {
  color: var(--text-soft);
  background: transparent;
  border-color: transparent;
}

.button-ghost:hover:not(:disabled) {
  color: var(--text);
  background: #eef2f7;
}

.button-danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.button-danger:hover:not(:disabled) {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

.button-small {
  min-height: 36px;
  padding: 7px 11px;
  font-size: 13px;
}

.button-block {
  width: 100%;
}

.button.is-loading .button-label {
  opacity: 0.72;
}

.button-spinner {
  display: none;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.button-secondary .button-spinner {
  border-color: rgba(23, 32, 51, 0.25);
  border-top-color: currentColor;
}

.button.is-loading .button-spinner {
  display: inline-block;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  padding: 0;
  place-items: center;
  color: var(--text-soft);
  font-size: 27px;
  line-height: 1;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
}

.icon-button:hover {
  color: var(--text);
  background: #eef2f7;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field label,
.label-row label {
  color: #2d3a4e;
  font-size: 14px;
  font-weight: 650;
}

.field small {
  color: var(--text-faint);
  font-size: 12px;
}

.field input,
.search-control input,
.select-control select,
.template-field select {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.field input:hover,
.search-control input:hover,
.select-control select:hover,
.template-field select:hover {
  border-color: #aab6c7;
}

.field input:focus,
.search-control input:focus,
.select-control select:focus,
.template-field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus);
}

.field input[readonly] {
  color: var(--text-soft);
  background: var(--surface-soft);
}

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

.caps-lock {
  color: var(--warning);
  font-size: 12px;
  font-weight: 650;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 66px;
}

.input-action {
  position: absolute;
  top: 50%;
  right: 5px;
  min-width: 52px;
  min-height: 34px;
  padding: 4px 8px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 650;
  background: transparent;
  border: 0;
  border-radius: 6px;
  transform: translateY(-50%);
}

.input-action:hover {
  background: var(--primary-soft);
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-message {
  margin: -3px 0 0;
  padding: 10px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.error-message {
  color: #9f2020;
  background: var(--danger-soft);
  border: 1px solid #f3caca;
}

.eyebrow,
.section-kicker {
  margin-bottom: 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.transport-warning {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 15px;
  color: #704500;
  background: var(--warning-soft);
  border: 1px solid #f0d899;
  border-radius: var(--radius);
}

.transport-warning strong {
  color: #684000;
}

.transport-warning p {
  margin: 3px 0 0;
  font-size: 13px;
}

.warning-icon {
  display: grid;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  place-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  background: #b36d00;
  border-radius: 50%;
}

.compact-warning {
  margin: 24px 0;
}

.compact-warning p {
  margin: 0;
}

.login-page {
  background:
    radial-gradient(circle at 18% 10%, rgba(52, 126, 236, 0.1), transparent 30%),
    radial-gradient(circle at 84% 88%, rgba(47, 107, 207, 0.08), transparent 30%),
    #f5f8fc;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  padding: 30px 18px;
  place-items: center;
}

.login-card {
  width: min(100%, 430px);
  padding: 34px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(211, 220, 233, 0.92);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.brand-login {
  margin-bottom: 33px;
}

.login-heading h1 {
  margin-bottom: 10px;
  font-size: clamp(26px, 6vw, 32px);
}

.login-heading > p:last-child {
  margin-bottom: 0;
  color: var(--text-soft);
  font-size: 14px;
}

.login-footnote {
  margin: 20px 0 0;
  color: var(--text-faint);
  font-size: 12px;
  text-align: center;
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.header-inner {
  display: flex;
  width: min(100% - 40px, 1280px);
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 0 auto;
}

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

.header-scope {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  color: var(--text-soft);
  font-size: 13px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.scope-dot {
  width: 7px;
  height: 7px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--success-soft);
}

.app-main {
  width: min(100% - 40px, 1280px);
  margin: 0 auto;
  padding: 28px 0 60px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin: 30px 0 22px;
}

.page-heading h1 {
  margin-bottom: 8px;
  font-size: clamp(28px, 4vw, 38px);
}

.page-heading p:last-child {
  margin-bottom: 0;
  color: var(--text-soft);
}

.scope-panel,
.balance-panel,
.instances-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.balance-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
  padding: 20px 22px;
  background:
    linear-gradient(120deg, rgba(23, 105, 224, 0.075), transparent 48%),
    var(--surface);
}

.balance-mark {
  display: grid;
  width: 46px;
  height: 46px;
  color: var(--primary);
  font-size: 22px;
  font-weight: 750;
  background: var(--surface-blue);
  border: 1px solid #cbdcfa;
  border-radius: 14px;
  place-items: center;
}

.balance-copy {
  min-width: 0;
}

.balance-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.balance-heading h2 {
  margin: 1px 0 7px;
  font-size: 15px;
  font-weight: 650;
}

.balance-amount {
  display: block;
  color: var(--text);
  font-size: clamp(28px, 4vw, 38px);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.balance-updated {
  margin: 7px 0 0;
  color: var(--text-faint);
  font-size: 12px;
}

.balance-updated.is-error {
  color: var(--danger);
}

.scope-panel {
  padding: 20px 22px;
}

.scope-panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.scope-panel-heading h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.scope-helper {
  margin: 5px 0 0;
  color: var(--text-faint);
  font-size: 12px;
}

.scope-panel-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.template-picker {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(180px, 0.7fr);
  gap: 14px;
  margin-bottom: 20px;
}

.template-field {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 650;
}

.template-field select {
  min-width: 0;
  padding-right: 34px;
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
}

.soft-badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 4px 9px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 650;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.soft-badge.is-ready {
  color: var(--success);
  background: var(--success-soft);
  border-color: #bce7d1;
}

.soft-badge.is-error {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #f0c6c6;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0;
  margin: 0;
}

.config-grid > div {
  min-width: 0;
  padding: 2px 17px;
  border-left: 1px solid var(--border);
}

.config-grid > div:first-child {
  padding-left: 0;
  border-left: 0;
}

.config-grid dt,
.operation-details dt,
.action-summary dt {
  margin-bottom: 5px;
  color: var(--text-faint);
  font-size: 12px;
}

.config-grid dd,
.operation-details dd,
.action-summary dd {
  margin: 0;
  color: #29364a;
  font-size: 14px;
  font-weight: 650;
}

.config-grid dd {
  overflow-wrap: anywhere;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 16px 0;
}

.metric-card {
  display: flex;
  min-height: 128px;
  flex-direction: column;
  justify-content: center;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.metric-label {
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 650;
}

.metric-card strong {
  margin: 6px 0 3px;
  color: var(--text);
  font-size: 30px;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.metric-hint {
  color: var(--text-faint);
  font-size: 12px;
}

.metric-running {
  color: var(--success);
}

.operation-banner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  margin: 16px 0;
  padding: 14px 16px;
  color: #24436e;
  background: var(--surface-blue);
  border: 1px solid #cbdcfa;
  border-radius: var(--radius);
}

.operation-banner strong {
  display: block;
  margin-bottom: 2px;
  font-size: 14px;
}

.operation-banner p {
  margin: 0;
  color: #536d91;
  font-size: 13px;
}

.operation-pulse {
  width: 10px;
  height: 10px;
  background: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(23, 105, 224, 0.35);
  animation: pulse 1.8s ease-out infinite;
}

.instances-panel {
  overflow: hidden;
}

.panel-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}

.panel-heading h2 {
  margin-bottom: 4px;
  font-size: 20px;
}

.panel-heading p {
  margin: 0;
  color: var(--text-faint);
  font-size: 12px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.search-control {
  position: relative;
  display: block;
  width: min(290px, 26vw);
}

.search-control > span:not(.sr-only) {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 12px;
  color: var(--text-faint);
  font-size: 20px;
  transform: translateY(-53%);
  pointer-events: none;
}

.search-control input {
  padding-left: 37px;
}

.select-control {
  display: block;
  min-width: 118px;
}

.select-control select {
  padding-right: 30px;
}

.refresh-icon {
  display: inline-block;
  font-size: 17px;
  line-height: 1;
}

.button.is-refreshing .refresh-icon {
  animation: spin 0.75s linear infinite;
}

.list-state {
  display: flex;
  min-height: 290px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-soft);
  text-align: center;
}

.list-state strong {
  margin-top: 15px;
  color: var(--text);
  font-size: 16px;
}

.list-state p {
  max-width: 430px;
  margin: 5px 0 0;
  font-size: 13px;
}

.list-state .button {
  margin-top: 18px;
}

.large-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #dbe4f1;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.instances-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.instances-table th {
  padding: 11px 16px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.045em;
  text-align: left;
  text-transform: uppercase;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.instances-table td {
  min-width: 108px;
  padding: 17px 16px;
  color: var(--text-soft);
  font-size: 13px;
  vertical-align: middle;
  border-bottom: 1px solid #e7ebf1;
}

.instances-table tbody tr:last-child td {
  border-bottom: 0;
}

.instances-table tbody tr:hover {
  background: #fbfcfe;
}

.instances-table th:first-child,
.instances-table td:first-child {
  padding-left: 22px;
}

.instances-table th:last-child,
.instances-table td:last-child {
  padding-right: 22px;
  text-align: right;
}

.instance-identity {
  display: flex;
  min-width: 190px;
  flex-direction: column;
  gap: 3px;
}

.instance-identity strong {
  max-width: 270px;
  overflow: hidden;
  color: #253248;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.instance-identity code {
  color: var(--text-faint);
  font-size: 11px;
}

.managed-label {
  display: inline-flex;
  width: max-content;
  margin-top: 4px;
  padding: 2px 6px;
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  background: var(--primary-soft);
  border-radius: 5px;
}

.status-badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 7px;
  padding: 4px 9px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 650;
  background: #f2f4f7;
  border-radius: 999px;
  white-space: nowrap;
}

.status-badge::before {
  width: 7px;
  height: 7px;
  content: "";
  background: #788598;
  border-radius: 50%;
}

.status-running {
  color: var(--success);
  background: var(--success-soft);
}

.status-running::before {
  background: var(--success);
}

.status-stopped {
  color: #5b6575;
  background: #eef1f4;
}

.status-stopped::before {
  background: #6a7586;
}

.status-pending {
  color: #825000;
  background: var(--warning-soft);
}

.status-pending::before {
  background: #b46d00;
  animation: blink 1.25s ease-in-out infinite;
}

.status-error {
  color: var(--danger);
  background: var(--danger-soft);
}

.status-error::before {
  background: var(--danger);
}

.cell-stack {
  display: flex;
  min-width: 120px;
  flex-direction: column;
  gap: 3px;
}

.cell-stack strong {
  color: #334158;
  font-size: 13px;
  font-weight: 600;
}

.cell-stack span {
  color: var(--text-faint);
  font-size: 11px;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 7px;
}

.row-actions .button {
  white-space: nowrap;
}

.power-note {
  margin: -4px 20px 16px;
  padding: 10px 12px;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.55;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.power-note code {
  color: #315481;
  font-size: 11px;
}

.remote-note {
  margin: -8px 20px 16px;
  padding: 10px 12px;
  color: #36516f;
  font-size: 12px;
  line-height: 1.55;
  background: #f3f8ff;
  border: 1px solid #cbdcf2;
  border-radius: 9px;
}

.remote-action-group {
  display: inline-flex;
  max-width: 190px;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.remote-button {
  color: #235f9d;
  border-color: #b9d1ea;
}

.remote-button:hover:not(:disabled) {
  color: #174f88;
  background: #eef6ff;
  border-color: #8db5dc;
}

.remote-reason {
  color: var(--text-faint);
  font-size: 10px;
  line-height: 1.35;
  text-align: right;
}

.start-button {
  color: var(--success);
  border-color: #b9dfcd;
}

.start-button:hover:not(:disabled) {
  color: #116a44;
  background: var(--success-soft);
  border-color: #92cfb2;
}

.stop-button {
  color: #7a5710;
  border-color: #e4d4ad;
}

.stop-button:hover:not(:disabled) {
  color: #644406;
  background: #fff8e6;
  border-color: #d7be82;
}

.destroy-button {
  color: var(--danger);
  background: #fff;
  border-color: #efc4c4;
}

.destroy-button:hover:not(:disabled) {
  color: #a41f1f;
  background: var(--danger-soft);
  border-color: #e9aaaa;
}

.instance-cards {
  display: none;
}

.filter-empty {
  padding: 46px 20px;
  color: var(--text-soft);
  text-align: center;
}

.filter-empty strong {
  color: var(--text);
}

.filter-empty p {
  margin: 4px 0 0;
  font-size: 13px;
}

.modal {
  width: min(calc(100% - 30px), 560px);
  max-height: min(90vh, 820px);
  padding: 0;
  overflow: auto;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 26px 80px rgba(17, 30, 52, 0.28);
}

.modal-wide {
  width: min(calc(100% - 30px), 650px);
}

.modal::backdrop {
  background: rgba(17, 27, 44, 0.55);
  backdrop-filter: blur(3px);
}

.modal-header {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px 17px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.modal-header h2 {
  margin-bottom: 0;
  font-size: 22px;
}

.danger-header .section-kicker,
.danger-header h2 {
  color: var(--danger);
}

.modal-body {
  padding: 23px 24px 25px;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 5px;
  padding-top: 3px;
}

.centered-actions {
  justify-content: center;
  margin-top: 22px;
}

.action-summary {
  margin-bottom: 18px;
  padding: 15px 17px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.action-summary dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px 20px;
  margin: 0;
}

.info-callout,
.danger-callout {
  margin-bottom: 20px;
  padding: 13px 15px;
  border-radius: var(--radius);
}

.info-callout {
  color: #335374;
  background: var(--surface-blue);
  border: 1px solid #cadcf9;
}

.danger-callout {
  color: #942424;
  background: var(--danger-soft);
  border: 1px solid #efc5c5;
}

.info-callout strong,
.danger-callout strong {
  display: block;
  margin-bottom: 3px;
  color: inherit;
  font-size: 14px;
}

.info-callout p,
.danger-callout p {
  margin: 0;
  color: inherit;
  font-size: 13px;
}

.target-instance {
  display: flex;
  margin-bottom: 20px;
  padding: 14px 15px;
  flex-direction: column;
  gap: 3px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.target-instance span {
  color: var(--text-faint);
  font-size: 11px;
}

.target-instance strong {
  color: var(--text);
  font-size: 15px;
}

.target-instance code {
  color: var(--text-soft);
  font-size: 12px;
}

.operation-pane {
  padding-top: 30px;
  text-align: center;
}

.operation-icon {
  display: grid;
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  place-items: center;
  color: var(--primary);
  font-size: 25px;
  font-weight: 700;
  background: var(--primary-soft);
  border-radius: 50%;
}

.operation-icon.is-working {
  animation: spin 1.2s linear infinite;
}

.operation-icon.is-success {
  color: var(--success);
  background: var(--success-soft);
  animation: none;
}

.operation-icon.is-error {
  color: var(--danger);
  background: var(--danger-soft);
  animation: none;
}

.danger-operation-icon {
  color: var(--danger);
  background: var(--danger-soft);
}

.operation-pane h3 {
  margin-bottom: 7px;
  font-size: 23px;
}

.operation-pane > p:not(.section-kicker) {
  max-width: 480px;
  margin-right: auto;
  margin-bottom: 19px;
  margin-left: auto;
  color: var(--text-soft);
}

.operation-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin: 0;
  text-align: left;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.operation-details > div {
  min-width: 0;
  padding: 12px 14px;
  background: var(--surface-soft);
}

.secret-panel {
  margin-top: 18px;
  padding: 16px;
  text-align: left;
  background: #fffaf0;
  border: 1px solid #ecd7a3;
  border-radius: var(--radius);
}

.secret-panel strong {
  display: block;
  margin-bottom: 4px;
  color: #6f4907;
  font-size: 14px;
}

.secret-panel p,
.muted-copy {
  margin: 0 0 13px;
  color: var(--text-soft);
  font-size: 13px;
}

.secret-panel .field {
  margin: 12px 0;
}

.secret-label {
  display: block;
  margin-bottom: 7px;
  color: #76540f;
  font-size: 12px;
  font-weight: 700;
}

.secret-value-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.secret-value-row code {
  display: flex;
  min-height: 42px;
  flex: 1;
  align-items: center;
  padding: 9px 11px;
  overflow: auto;
  color: #30260f;
  font-size: 15px;
  font-weight: 700;
  background: #fff;
  border: 1px solid #ddc58d;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.toast-region {
  position: fixed;
  z-index: 1000;
  right: 20px;
  bottom: 20px;
  display: flex;
  width: min(calc(100% - 40px), 390px);
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  padding: 13px 14px;
  color: #fff;
  background: #25344b;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  animation: toast-in 0.2s ease-out;
}

.toast::before {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  content: "✓";
  background: rgba(255, 255, 255, 0.16);
  border-radius: 50%;
}

.toast.is-error {
  background: #8d2626;
}

.toast.is-error::before {
  content: "!";
}

.toast strong {
  display: block;
  margin-bottom: 2px;
  font-size: 13px;
}

.toast p {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
}

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

@keyframes pulse {
  70% {
    box-shadow: 0 0 0 8px rgba(23, 105, 224, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(23, 105, 224, 0);
  }
}

@keyframes blink {
  50% {
    opacity: 0.38;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (max-width: 980px) {
  .config-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    row-gap: 18px;
  }

  .config-grid > div:nth-child(4) {
    padding-left: 0;
    border-left: 0;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    justify-content: stretch;
  }

  .search-control {
    width: auto;
    flex: 1;
  }
}

@media (max-width: 760px) {
  .header-inner,
  .app-main {
    width: min(100% - 28px, 1280px);
  }

  .header-scope {
    display: none;
  }

  .app-main {
    padding-top: 18px;
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
    margin-top: 23px;
  }

  .page-heading .button {
    align-self: flex-start;
  }

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

  .config-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .config-grid > div {
    padding-left: 14px;
  }

  .config-grid > div:nth-child(odd) {
    padding-left: 0;
    border-left: 0;
  }

  .config-grid > div:nth-child(4) {
    padding-left: 14px;
    border-left: 1px solid var(--border);
  }

  .table-scroll {
    display: none;
  }

  .instance-cards {
    display: grid;
    gap: 12px;
    padding: 14px;
  }

  .instance-card {
    padding: 16px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  .instance-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 15px;
  }

  .instance-card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin: 0 0 16px;
  }

  .instance-card-grid dt {
    margin-bottom: 3px;
    color: var(--text-faint);
    font-size: 11px;
  }

  .instance-card-grid dd {
    margin: 0;
    overflow-wrap: anywhere;
    color: #344158;
    font-size: 13px;
    font-weight: 600;
  }

  .instance-card .row-actions .button {
    flex: 1;
  }
}

@media (max-width: 560px) {
  .login-shell {
    padding: 0;
    place-items: stretch;
  }

  .login-card {
    display: flex;
    width: 100%;
    min-height: 100vh;
    padding: 28px 22px;
    flex-direction: column;
    justify-content: center;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .app-header .brand small {
    display: none;
  }

  .header-inner {
    width: calc(100% - 22px);
  }

  .app-main {
    width: calc(100% - 22px);
    padding-bottom: 34px;
  }

  .transport-warning {
    border-radius: var(--radius-sm);
  }

  .page-heading h1 {
    font-size: 28px;
  }

  .page-heading .button {
    width: 100%;
  }

  .scope-panel {
    padding: 17px;
  }

  .scope-panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .scope-panel-actions {
    justify-content: space-between;
  }

  .scope-panel-actions .button {
    flex: 1;
  }

  .balance-panel {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 14px;
    padding: 17px;
  }

  .balance-heading {
    flex-direction: column;
    gap: 7px;
  }

  .balance-panel > .button {
    width: 100%;
    grid-column: 1 / -1;
  }

  .config-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .config-grid > div,
  .config-grid > div:nth-child(4) {
    padding: 10px 0;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .config-grid > div:first-child {
    padding-top: 0;
    border-top: 0;
  }

  .metrics-grid {
    gap: 10px;
  }

  .metric-card {
    min-height: 112px;
    padding: 15px;
  }

  .metric-card strong {
    font-size: 27px;
  }

  .operation-banner {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .operation-banner .button {
    grid-column: 1 / -1;
  }

  .panel-heading {
    padding: 17px;
  }

  .toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .search-control {
    grid-column: 1 / -1;
  }

  .modal {
    width: 100%;
    max-width: none;
    max-height: 96vh;
    margin: auto 0 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 18px 18px 0 0;
  }

  .modal-header {
    padding: 18px 18px 14px;
  }

  .modal-body {
    padding: 19px 18px 24px;
  }

  .action-summary dl,
  .operation-details {
    grid-template-columns: 1fr;
  }

  .modal-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .modal-actions .button {
    width: 100%;
  }

  .centered-actions {
    flex-direction: column;
  }

  .secret-value-row {
    flex-direction: column;
  }

  .toast-region {
    right: 12px;
    bottom: 12px;
    width: calc(100% - 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
