:root {
  color-scheme: light;
  --bg: #fff7fb;
  --surface: #ffffff;
  --surface-2: #fff0f6;
  --surface-3: #ffe2ee;
  --text: #342432;
  --muted: #7f6678;
  --line: #f3ccdc;
  --strong-line: #e9a7c3;
  --pink: #ea5b98;
  --pink-strong: #d83c82;
  --pink-soft: #ffd6e6;
  --rose: #b92266;
  --green: #1a8b62;
  --amber: #a66500;
  --red: #b52245;
  --shadow: 0 18px 60px rgba(211, 62, 128, 0.14);
  --radius: 8px;
  --radius-sm: 6px;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 232, 242, 0.95), rgba(255, 247, 251, 1) 360px),
    var(--bg);
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  z-index: 80;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid var(--strong-line);
  border-radius: var(--radius);
  color: var(--rose);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-panel {
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

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

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--pink), #ff8ab8);
  box-shadow: 0 8px 22px rgba(216, 60, 130, 0.25);
}

.brand-mark.small {
  width: 34px;
  height: 34px;
}

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

h1 {
  margin-bottom: 0;
  font-size: 26px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: 26px;
  line-height: 1.18;
}

h3 {
  margin-bottom: 12px;
  font-size: 17px;
  line-height: 1.3;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--pink-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-copy,
.fine-print,
.muted {
  color: var(--muted);
}

.login-copy {
  margin: 18px 0;
}

.fine-print {
  margin: 14px 0 0;
  font-size: 13px;
  line-height: 1.5;
}

.stack-form,
.filter-form,
.inline-form {
  display: grid;
  gap: 12px;
}

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

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

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

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  color: var(--text);
  background: #fff;
  outline: none;
}

textarea {
  min-height: 118px;
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(234, 91, 152, 0.16);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 0;
}

.checkbox-label input {
  width: 18px;
  min-height: 18px;
}

.primary-button,
.soft-button,
.ghost-button,
.danger-button,
.table-button {
  min-height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 8px 12px;
  font-weight: 750;
  white-space: nowrap;
}

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

.primary-button:hover {
  background: var(--rose);
}

.soft-button {
  color: var(--rose);
  border-color: var(--line);
  background: var(--surface-2);
}

.soft-button:hover {
  border-color: var(--strong-line);
  background: var(--surface-3);
}

.ghost-button {
  color: var(--rose);
  border-color: var(--line);
  background: transparent;
}

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

.table-button {
  min-height: 30px;
  padding: 5px 9px;
  color: var(--rose);
  border-color: var(--line);
  background: #fff;
  font-size: 12px;
}

.wide {
  width: 100%;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(14px);
}

.sidebar-brand strong {
  display: block;
}

.sidebar-brand small {
  display: block;
  max-width: 150px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-nav {
  display: grid;
  align-content: start;
  gap: 8px;
}

.side-nav button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-weight: 750;
}

.side-nav button.active,
.side-nav button:hover {
  color: var(--rose);
  border-color: var(--line);
  background: var(--surface-2);
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.view-root {
  display: grid;
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 36px rgba(216, 60, 130, 0.08);
}

.panel-header,
.panel-body {
  padding: 16px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.panel-header h3 {
  margin: 0;
}

.panel-actions,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.metric-card {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(216, 60, 130, 0.08);
}

.metric-card span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 28px;
  line-height: 1.1;
}

.metric-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 18px;
}

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

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

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  background: #fffafd;
}

td {
  font-size: 13px;
}

.nowrap {
  white-space: nowrap;
}

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

.copyable {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.badge.active,
.badge.ok {
  color: var(--green);
  border-color: rgba(26, 139, 98, 0.22);
  background: rgba(26, 139, 98, 0.08);
}

.badge.paused,
.badge.warn {
  color: var(--amber);
  border-color: rgba(166, 101, 0, 0.22);
  background: rgba(166, 101, 0, 0.08);
}

.badge.deleted,
.badge.danger,
.badge.revoked {
  color: var(--red);
  border-color: rgba(181, 34, 69, 0.22);
  background: rgba(181, 34, 69, 0.08);
}

.badge.admin {
  color: var(--rose);
  border-color: var(--line);
  background: var(--surface-2);
}

.empty-state {
  display: grid;
  min-height: 140px;
  place-items: center;
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.chart {
  display: grid;
  grid-template-columns: repeat(30, minmax(8px, 1fr));
  align-items: end;
  gap: 5px;
  min-height: 180px;
  padding: 12px 2px 2px;
}

.bar {
  min-height: 4px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #ff8ab8, var(--pink-strong));
}

.mode-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.mode-pill {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--rose);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 750;
}

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

.detail-title {
  min-width: 0;
}

.detail-title h3 {
  margin: 0 0 6px;
  overflow-wrap: anywhere;
}

.modal-root {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(52, 36, 50, 0.36);
}

.modal-panel {
  width: min(920px, 100%);
  max-height: min(82vh, 760px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-panel header h3 {
  margin: 0;
}

.modal-body {
  overflow: auto;
  padding: 16px;
}

pre {
  min-width: 0;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #493747;
  font-size: 12px;
  line-height: 1.55;
}

.loading {
  display: grid;
  min-height: 240px;
  place-items: center;
  color: var(--muted);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

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

  .sidebar {
    position: static;
    height: auto;
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .side-nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .side-nav button {
    flex: 0 0 auto;
  }

  .workspace {
    padding: 16px;
  }

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

  .two-column,
  .three-column,
  .split-column {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .login-screen {
    padding: 16px;
  }

  .login-panel {
    padding: 20px;
  }

  .topbar,
  .panel-header,
  .detail-head {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid,
  .grid-form,
  .grid-form.compact {
    grid-template-columns: 1fr;
  }

  .workspace {
    padding: 12px;
  }

  h1,
  h2 {
    font-size: 22px;
  }

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

  .panel-header,
  .panel-body {
    padding: 13px;
  }

  .action-row,
  .panel-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-row button,
  .panel-actions button {
    white-space: normal;
  }
}
