:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d8dee8;
  --primary: #146c5d;
  --primary-dark: #0f554a;
  --accent: #b8325f;
  --warn: #9a5b00;
  --shadow: 0 18px 42px rgba(20, 30, 40, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(20, 108, 93, 0.12), transparent 38%),
    linear-gradient(310deg, rgba(184, 50, 95, 0.10), transparent 42%),
    var(--bg);
}

.login-panel {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

.muted {
  color: var(--muted);
}

.form-stack {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: #344054;
  font-size: 14px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus {
  outline: 2px solid rgba(20, 108, 93, 0.18);
  border-color: var(--primary);
}

.primary,
.secondary,
.ghost,
.nav-item {
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 9px 14px;
  font-weight: 700;
}

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

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

.secondary {
  color: var(--primary);
  border-color: rgba(20, 108, 93, 0.32);
  background: #eef8f5;
}

.ghost {
  color: #344054;
  border-color: var(--line);
  background: #fff;
}

.ghost.danger {
  color: #b42318;
  border-color: #f4b8b2;
}

.full {
  width: 100%;
}

.error {
  min-height: 20px;
  color: #b42318;
  margin: 0;
}

.message {
  min-height: 22px;
  margin: 0;
  color: var(--primary);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  background: #18212b;
  color: #fff;
}

.sidebar h2 {
  margin-bottom: 0;
}

.sidebar .eyebrow {
  color: #74d6c6;
}

.sidebar nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  text-align: left;
  color: #d0d7e2;
  background: transparent;
  border-color: transparent;
}

.nav-item.active,
.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.sidebar .ghost {
  margin-top: auto;
  color: #fff;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.22);
}

.content {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.topbar h1 {
  margin-bottom: 6px;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
}

.toolbar input {
  width: min(360px, 42vw);
}

.user-menu-wrap {
  position: relative;
}

.user-menu-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: #344054;
  background: #fff;
  font-weight: 800;
}

.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  min-width: 148px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 36px rgba(16, 24, 40, 0.14);
}

.user-menu button {
  width: 100%;
  justify-content: flex-start;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 8px 10px;
  color: #344054;
  background: transparent;
}

.user-menu button:hover {
  background: #f2f4f7;
}

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

.metric {
  min-height: 96px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric span {
  font-size: 30px;
  font-weight: 800;
}

.metric small {
  color: var(--muted);
  font-weight: 700;
}

.table-wrap,
.editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: #475467;
  background: #f9fafb;
  font-size: 13px;
}

td {
  font-size: 14px;
}

.cell-title {
  font-weight: 800;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--primary);
  background: #eaf7f3;
  font-size: 12px;
  font-weight: 800;
}

.badge.warn {
  color: var(--warn);
  background: #fff4df;
}

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

.row-actions button {
  min-height: 32px;
  padding: 6px 9px;
}

.row-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.editor {
  padding: 22px;
}

.editor.narrow {
  max-width: 860px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 6px 0 14px;
}

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

.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 24px;
}

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

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

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 10px;
}

.check-row {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.notice {
  padding: 14px;
  border: 1px solid #f2d8a7;
  border-radius: 6px;
  color: #7a4b00;
  background: #fff8e8;
  line-height: 1.6;
}

.integration-editor {
  margin-top: 18px;
}

.code-area {
  min-height: 180px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  resize: vertical;
}

.inline-check {
  margin: 0 auto 0 0;
}

.account-layout {
  display: grid;
  grid-template-columns: minmax(320px, 520px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.account-editor,
.account-table {
  min-width: 0;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
  margin: -4px 0 22px;
}

.permission-grid .check-row {
  margin: 0;
  font-weight: 650;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .sidebar nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .topbar,
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar input {
    width: 100%;
  }

  .user-menu-wrap,
  .user-menu-button {
    width: 100%;
  }

  .metrics,
  .grid.two,
  .grid.three,
  .account-layout,
  .permission-grid {
    grid-template-columns: 1fr;
  }

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

  table {
    min-width: 820px;
  }
}
