:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-muted: #f8f9fa;
  --text: #18212a;
  --text-muted: #64707d;
  --line: #dce1e5;
  --line-strong: #c7ced4;
  --accent: #c63d32;
  --accent-dark: #9f2f27;
  --green: #237a52;
  --green-bg: #eaf5ef;
  --amber: #94610a;
  --amber-bg: #fff4d8;
  --red: #a8322b;
  --red-bg: #fbecea;
  --blue: #2f6294;
  --blue-bg: #eaf1f8;
  --shadow: 0 14px 32px rgba(24, 33, 42, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
input,
select,
dialog {
  border-radius: 6px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(47, 98, 148, 0.26);
  outline-offset: 1px;
}

[hidden] {
  display: none !important;
}

.mobile-only {
  display: none;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: var(--bg);
}

.login-panel {
  width: min(430px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-lockup div {
  display: grid;
  line-height: 1.1;
}

.brand-lockup strong {
  font-size: 15px;
  letter-spacing: 0;
}

.brand-lockup div span {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}

.login-heading {
  margin: 42px 0 28px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.login-heading h1,
.topbar h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

.login-heading p:last-child,
.page-subtitle {
  margin: 8px 0 0;
  color: var(--text-muted);
}

.login-form {
  display: grid;
  gap: 18px;
}

.login-form label {
  display: grid;
  gap: 7px;
  font-weight: 650;
}

input,
select,
textarea {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  padding: 8px 11px;
}

textarea {
  resize: vertical;
}

input::placeholder {
  color: #919ba4;
}

.form-error {
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

.form-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.login-meta {
  margin: 24px 0 0;
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
}

.button {
  min-height: 36px;
  border: 1px solid transparent;
  padding: 7px 13px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

.button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.button-primary,
.button-danger {
  background: var(--accent);
  color: #fff;
}

.button-primary:hover,
.button-danger:hover {
  background: var(--accent-dark);
}

.button-secondary {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.button-secondary:hover,
.button-quiet:hover {
  background: var(--surface-muted);
}

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

.button-small {
  min-height: 30px;
  padding: 4px 9px;
  font-size: 12px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #2c353d;
  background: #202930;
  color: #fff;
}

.sidebar-brand {
  min-height: 76px;
  padding: 18px 20px;
  border-bottom: 1px solid #343e46;
}

.sidebar-brand div span,
.current-user {
  color: #aeb8c0;
}

.main-nav {
  display: grid;
  gap: 3px;
  padding: 14px 10px;
}

.main-nav button {
  min-height: 40px;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: #c7d0d7;
  padding: 9px 13px;
  cursor: pointer;
  text-align: left;
  font-weight: 650;
}

.main-nav button:hover {
  background: #2a343c;
  color: #fff;
}

.main-nav button[aria-selected="true"] {
  border-left-color: #f06a5f;
  background: #313b43;
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 4px;
  padding: 16px 20px;
  border-top: 1px solid #343e46;
}

.sidebar-footer .button-quiet {
  justify-self: start;
  color: #d2d9de;
}

.current-user {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  min-width: 0;
}

.topbar {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

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

.api-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.api-status i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.api-status.is-error i {
  background: var(--red);
}

.content {
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px 28px 42px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 26px;
}

.metric {
  min-height: 108px;
  display: grid;
  align-content: space-between;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 16px;
}

.metric span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
}

.metric strong {
  font-size: 28px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metric small {
  color: var(--text-muted);
  font-size: 11px;
}

.metric.is-alert {
  border-color: #e5b1ac;
}

.metric.is-alert strong {
  color: var(--red);
}

.section-block {
  margin-top: 28px;
}

.section-heading,
.toolbar,
.table-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-heading {
  margin-bottom: 11px;
}

.section-heading h2 {
  margin: 0;
  font-size: 15px;
}

.section-heading p,
.table-meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.toolbar {
  margin-bottom: 14px;
  align-items: flex-end;
}

.filter-form {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 9px;
}

.filter-form label {
  display: grid;
  gap: 5px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

.filter-form input {
  width: 260px;
}

.filter-form select {
  min-width: 130px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
}

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

.pagination-actions {
  display: flex;
  gap: 7px;
}

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

th,
td {
  height: 46px;
  padding: 9px 12px;
  border-bottom: 1px solid #e7eaed;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
}

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

tbody tr:hover td {
  background: #fafbfc;
}

.cell-main {
  display: grid;
  gap: 2px;
}

.cell-main strong {
  font-size: 13px;
}

.cell-main span,
.muted {
  color: var(--text-muted);
  font-size: 11px;
}

.mono {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
}

.number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.positive {
  color: var(--green);
  font-weight: 750;
}

.negative {
  color: var(--red);
  font-weight: 750;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 4px;
  padding: 3px 7px;
  background: #eef1f3;
  color: #4b5761;
  font-size: 11px;
  font-weight: 750;
}

.badge-green {
  background: var(--green-bg);
  color: var(--green);
}

.badge-amber {
  background: var(--amber-bg);
  color: var(--amber);
}

.badge-red {
  background: var(--red-bg);
  color: var(--red);
}

.badge-blue {
  background: var(--blue-bg);
  color: var(--blue);
}

.empty-state,
.error-state,
.loading-state {
  min-height: 260px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  text-align: center;
}

.loading-state span {
  display: block;
  width: 28px;
  height: 28px;
  margin: 0 auto 12px;
  border: 3px solid #d8dde1;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.confirm-dialog {
  width: min(440px, calc(100% - 32px));
  border: 1px solid var(--line-strong);
  background: var(--surface);
  padding: 0;
  box-shadow: var(--shadow);
}

.confirm-dialog::backdrop {
  background: rgba(17, 25, 32, 0.48);
}

.confirm-dialog form {
  padding: 24px;
}

.secret-result-dialog {
  width: min(520px, calc(100% - 32px));
}

.secret-field {
  display: grid;
  gap: 6px;
  margin-top: 18px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 750;
}

.secret-field input {
  width: 100%;
  color: var(--text);
  font-size: 13px;
}

.copy-status {
  min-height: 20px;
  margin: 7px 0 0 !important;
  color: var(--green) !important;
  font-size: 12px;
}

.detail-dialog {
  width: min(560px, 100%);
  height: 100vh;
  max-height: 100vh;
  margin: 0 0 0 auto;
  border: 0;
  border-left: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--surface);
  padding: 0;
  box-shadow: -12px 0 30px rgba(24, 33, 42, 0.14);
}

.detail-dialog::backdrop {
  background: rgba(17, 25, 32, 0.42);
}

.detail-shell {
  height: 100%;
  overflow-y: auto;
  padding: 24px;
}

.detail-content {
  margin-top: 22px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.detail-grid > div {
  min-width: 0;
  display: grid;
  gap: 5px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px;
}

.detail-grid span {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 750;
}

.detail-grid strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.detail-section {
  margin-top: 22px;
}

.detail-section h3 {
  margin: 0 0 9px;
  font-size: 13px;
}

.detail-json {
  overflow-x: auto;
  margin: 0;
  border: 1px solid var(--line);
  background: var(--surface-muted);
  padding: 12px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 11px;
  white-space: pre-wrap;
}

.form-dialog {
  width: min(900px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  padding: 0;
  box-shadow: var(--shadow);
}

.compact-form-dialog {
  width: min(620px, calc(100% - 32px));
}

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

.form-dialog::backdrop {
  background: rgba(17, 25, 32, 0.48);
}

.operation-form {
  max-height: calc(100vh - 34px);
  overflow-y: auto;
  padding: 24px;
}

.dialog-header,
.form-dialog-actions,
.form-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 20px;
}

.dialog-header p:last-child {
  margin: 6px 0 0;
  color: var(--text-muted);
}

.dialog-close {
  padding-inline: 8px;
}

.form-section {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.form-section-heading {
  margin-bottom: 14px;
}

.form-section-heading h3 {
  margin: 0;
  font-size: 14px;
}

.form-section-heading span {
  color: var(--text-muted);
  font-size: 11px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.form-grid label {
  min-width: 0;
  display: grid;
  align-content: end;
  gap: 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 750;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
}

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

.field-span-3 {
  grid-column: span 3;
}

.checkbox-field {
  display: flex !important;
  align-items: center;
  align-self: end;
  gap: 8px !important;
  min-height: 40px;
  color: var(--text) !important;
  font-size: 12px !important;
}

.checkbox-field input {
  width: 16px;
  min-height: 16px;
  margin: 0;
}

.command-checks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.command-checks .checkbox-field {
  border: 1px solid var(--line);
  background: var(--surface-muted);
  padding: 10px 12px;
}

.safety-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
  border-left: 3px solid var(--green);
  background: var(--green-bg);
  color: var(--green);
  padding: 11px 13px;
  font-size: 12px;
}

.safety-strip span {
  color: #356c52;
}

.form-dialog .form-error {
  margin-top: 14px;
  border-left: 3px solid var(--red);
  background: var(--red-bg);
  padding: 10px 12px;
}

.form-dialog-actions {
  justify-content: flex-end;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.deployment-context {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-top: 20px;
  border: 1px solid var(--line);
  background: var(--line);
}

.deployment-context div {
  min-width: 0;
  display: grid;
  gap: 5px;
  background: var(--surface-muted);
  padding: 12px;
}

.deployment-context span {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 750;
}

.deployment-context strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dry-run-result {
  margin-top: 16px;
  border: 1px solid #9dcbb4;
  background: var(--green-bg);
  padding: 14px;
}

.dry-run-result > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--green);
}

.dry-run-result > div span {
  font-size: 10px;
  font-weight: 800;
}

.dry-run-result p {
  margin: 8px 0 4px;
  color: #356c52;
  font-size: 12px;
}

.confirmation-check {
  margin-top: 8px;
}

.confirm-dialog h2 {
  margin: 0 0 9px;
  font-size: 19px;
}

.confirm-dialog p {
  color: var(--text-muted);
}

.dialog-target {
  display: grid;
  gap: 4px;
  margin: 18px 0;
  border-left: 3px solid var(--accent);
  background: var(--surface-muted);
  padding: 12px 14px;
}

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

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 22px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: 360px;
  border-left: 4px solid var(--green);
  border-radius: 4px;
  background: #1f292f;
  color: #fff;
  padding: 12px 15px;
  box-shadow: var(--shadow);
}

@media (max-width: 1100px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
  }

  .sidebar-brand {
    min-height: 62px;
  }

  .main-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    padding: 8px 10px;
  }

  .main-nav button {
    min-width: 0;
    border-left: 0;
    border-bottom: 3px solid transparent;
    padding: 9px 4px;
    text-align: center;
    white-space: nowrap;
  }

  .main-nav button[aria-selected="true"] {
    border-bottom-color: #f06a5f;
  }

  .sidebar-footer {
    display: none;
  }

  .topbar {
    min-height: 82px;
    align-items: flex-start;
    padding: 16px;
  }

  .topbar h1 {
    font-size: 20px;
  }

  .api-status {
    display: none;
  }

  .mobile-only {
    display: inline-flex;
  }

  .content {
    padding: 16px 14px 32px;
  }

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

  .metric {
    min-height: 98px;
    padding: 13px;
  }

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

  .toolbar,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .pagination-actions {
    width: 100%;
  }

  .pagination-actions .button {
    flex: 1;
  }

  .detail-dialog {
    width: 100%;
  }

  .detail-shell {
    padding: 18px 16px;
  }

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

  .filter-form,
  .filter-form label,
  .filter-form input,
  .filter-form select {
    width: 100%;
  }

  .form-dialog {
    width: calc(100% - 16px);
    max-height: calc(100vh - 16px);
  }

  .operation-form {
    max-height: calc(100vh - 18px);
    padding: 18px 16px;
  }

  .dialog-header {
    align-items: flex-start;
  }

  .form-grid,
  .command-checks,
  .deployment-context {
    grid-template-columns: 1fr;
  }

  .field-span-2,
  .field-span-3 {
    grid-column: span 1;
  }

  .form-section-heading,
  .safety-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-dialog-actions {
    flex-wrap: wrap;
  }

  .login-view {
    padding: 14px;
    background: var(--bg);
  }

  .login-panel {
    padding: 26px 22px;
  }
}
