:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #dfe5ee;
  --blue: #1d5fd1;
  --blue-soft: #eaf2ff;
  --green: #138a62;
  --green-soft: #e9f7f1;
  --amber: #a15c07;
  --amber-soft: #fff3dc;
  --red: #c7352b;
  --red-soft: #fff0ee;
  --radius: 8px;
  --shadow: 0 10px 24px rgba(20, 31, 52, 0.07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

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

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  font-weight: 750;
  cursor: pointer;
}

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

input, select, textarea {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: #fff;
  color: var(--text);
}

textarea {
  width: 100%;
  min-height: 170px;
  padding: 12px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.45;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 12px;
  border-right: 1px solid var(--line);
  background: #fff;
  overflow: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 22px;
}

.brandMark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: var(--blue);
  color: #fff;
  font-weight: 900;
}

.brand strong, .brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 5px;
}

.navItem {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  border-color: transparent;
  background: transparent;
  color: #344054;
}

.navItem.active {
  background: var(--blue-soft);
  border-color: #cfe0ff;
  color: var(--blue);
}

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

.topbar {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.tenant span, .tenant strong {
  display: block;
}

.tenant span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

#globalSearch {
  width: min(420px, 38vw);
}

.iconButton {
  width: 38px;
  padding: 0;
}

.userBadge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}

.userBadge span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.pageHead {
  margin: 14px 0 18px;
}

.pageHead h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.pageHead p {
  margin: 6px 0 0;
  color: var(--muted);
  font-weight: 650;
}

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

.kpi, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.kpi {
  padding: 16px;
}

.kpi span, .kpi small {
  display: block;
  color: var(--muted);
  font-weight: 750;
}

.kpi strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 26px;
  line-height: 1;
}

.actionStrip, .toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.accountForm {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.accountForm label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
}

.formGrid {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(140px, 220px);
  gap: 12px;
}

.formActions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.formActions span {
  color: var(--muted);
  font-weight: 750;
}

.twoColumn {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 16px;
}

.panel {
  margin-bottom: 16px;
  overflow: hidden;
}

.panelHead {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.panelHead h2 {
  margin: 0;
  font-size: 16px;
}

.panelHead span {
  color: var(--muted);
  font-weight: 750;
}

.tableWrap {
  width: 100%;
  overflow: auto;
}

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

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

th {
  background: #fbfcfe;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  background: #eef2f6;
  color: #475467;
}

.badge.good { background: var(--green-soft); color: var(--green); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.bad { background: var(--red-soft); color: var(--red); }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tab.active {
  border-color: #cfe0ff;
  background: var(--blue-soft);
  color: var(--blue);
}

.feed, .notificationList, .featureList {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.feedItem, .notice, .feature {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
}

.feedItem p, .notice p {
  margin: 8px 0;
  color: var(--muted);
}

.feedItem small, .notice small, .feature small {
  color: var(--muted);
  font-weight: 700;
}

.notice div, .feature {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settingsGrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 1px;
  padding: 0;
  background: var(--line);
}

.settingsGrid article {
  min-height: 92px;
  padding: 16px;
  background: #fff;
}

.settingsGrid span, .settingsGrid strong {
  display: block;
}

.settingsGrid span {
  color: var(--muted);
  font-weight: 750;
  margin-bottom: 8px;
}

@media (max-width: 980px) {
  .portal {
    grid-template-columns: 1fr;
  }

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

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

  .main {
    padding: 0 16px 40px;
  }

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

  #globalSearch {
    width: 100%;
  }

  .kpiGrid, .twoColumn, .settingsGrid, .formGrid {
    grid-template-columns: 1fr;
  }
}
