:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #162033;
  --muted: #667085;
  --line: #e6ebf2;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --shadow: 0 18px 45px rgba(22, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), transparent 30rem),
    linear-gradient(135deg, #eef5ff 0%, var(--bg) 42%, #f8fbff 100%);
  font-family:
    "PingFang SC",
    "Microsoft YaHei",
    "Noto Sans SC",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

#app[hidden],
.login-screen[hidden] {
  display: none;
}

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

.login-card {
  display: grid;
  width: min(460px, 100%);
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.login-brand {
  padding: 0;
}

.login-button {
  width: 100%;
  min-height: 44px;
}

.login-error {
  padding: 10px 12px;
  color: #991b1b;
  border-radius: 12px;
  background: #fee2e2;
}

.sidebar {
  padding: 24px 18px;
  border-right: 1px solid rgba(230, 235, 242, 0.9);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: white;
  font-weight: 800;
  border-radius: 14px;
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  box-shadow: 0 14px 26px rgba(37, 99, 235, 0.28);
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
}

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

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

.nav button {
  width: 100%;
  padding: 12px 14px;
  color: var(--muted);
  text-align: left;
  border: 0;
  border-radius: 14px;
  background: transparent;
}

.nav button.active {
  color: var(--primary);
  background: rgba(37, 99, 235, 0.1);
  font-weight: 700;
}

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

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

h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.03em;
}

p {
  margin: 8px 0 0;
  color: var(--muted);
}

.topbar-actions,
.toolbar,
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.primary-button,
.ghost-button,
.danger-button,
.success-button {
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
}

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

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

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

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

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

.config-card,
.panel,
.metric-card,
.empty-state,
.toast {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.config-card {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr)) minmax(220px, 0.8fr);
  gap: 14px;
  align-items: end;
  padding: 16px;
  margin-bottom: 18px;
}

.toolbar input,
.toolbar select {
  width: auto;
  min-width: 180px;
}

label span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

input,
select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
}

.config-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.toast {
  padding: 12px 14px;
  margin-bottom: 16px;
  color: #075985;
  background: #e0f2fe;
}

.toast.error {
  color: #991b1b;
  background: #fee2e2;
}

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

.metric-card {
  padding: 18px;
}

.metric-value {
  font-size: 30px;
  font-weight: 850;
}

.metric-label {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

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

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.panel-title {
  font-size: 16px;
  font-weight: 800;
}

.panel-body {
  padding: 16px;
}

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

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

th {
  color: var(--muted);
  font-weight: 800;
  background: #fbfdff;
}

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

.status {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  background: #e5e7eb;
  color: #374151;
}

.status.success {
  color: #166534;
  background: #dcfce7;
}

.status.warning {
  color: #92400e;
  background: #fef3c7;
}

.status.danger {
  color: #991b1b;
  background: #fee2e2;
}

.status.primary {
  color: #1d4ed8;
  background: #dbeafe;
}

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

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

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.nowrap {
  white-space: nowrap;
}

.break-all {
  word-break: break-all;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.check-item input {
  width: auto;
  height: auto;
}

.permission-actions {
  margin-top: 14px;
}

@media (max-width: 960px) {
  #app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 14px;
  }

  .nav {
    display: flex;
    overflow-x: auto;
  }

  .nav button {
    min-width: 128px;
  }

  .main {
    padding: 18px;
  }

  .topbar,
  .panel-header {
    flex-direction: column;
  }

  .config-card,
  .metrics-grid,
  .two-column {
    grid-template-columns: 1fr;
  }

  table {
    display: block;
    overflow-x: auto;
  }
}
