:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --line: #d9e1ea;
  --line-strong: #b7c4d2;
  --text: #17202a;
  --muted: #5f6f82;
  --blue: #2563eb;
  --blue-strong: #1d4ed8;
  --green: #16794c;
  --red: #c03535;
  --amber: #a46012;
  --focus: rgba(37, 99, 235, 0.24);
  --shadow: 0 10px 30px rgba(23, 32, 42, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}

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

button {
  border: 0;
  cursor: pointer;
}

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

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

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

.login-panel h1 {
  margin: 0 0 22px;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: 0;
}

.shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  min-width: 190px;
  flex-direction: column;
  gap: 2px;
}

.brand strong {
  font-size: 17px;
}

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

.nav {
  display: flex;
  flex: 1;
  justify-content: center;
  gap: 6px;
}

.nav button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.nav button.active {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.page {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 24px 28px 44px;
}

.page-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.page-title h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.page-title p {
  margin: 6px 0 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

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

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(23, 32, 42, 0.04);
}

.panel-body {
  padding: 18px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field label,
.field-title {
  color: #344255;
  font-size: 13px;
  font-weight: 600;
}

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

.field textarea {
  min-height: 86px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.search-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--focus);
}

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

.permission-grid label {
  display: flex;
  align-items: center;
  min-height: 38px;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
  color: var(--text);
  font-weight: 500;
}

.permission-grid input {
  width: 16px;
  height: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  gap: 6px;
  padding: 0 14px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}

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

.btn.primary:hover {
  background: var(--blue-strong);
}

.btn.ghost {
  border: 1px solid var(--line);
  background: #fff;
}

.btn.danger {
  background: #fff0f0;
  color: var(--red);
}

.btn.warning {
  background: #fff6e8;
  color: var(--amber);
}

.btn.success {
  background: #eaf7ef;
  color: var(--green);
}

.btn.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

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

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

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

th {
  background: #f9fbfd;
  color: #48576a;
  font-size: 13px;
  font-weight: 700;
}

td {
  line-height: 1.45;
}

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

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

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e9f1ff;
  color: #1d4f91;
  font-size: 12px;
  font-weight: 700;
}

.pill.empty {
  background: #f1f3f5;
  color: var(--muted);
}

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

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

.alert {
  margin-bottom: 14px;
  padding: 11px 13px;
  border: 1px solid #f1c6c6;
  border-radius: 6px;
  background: #fff7f7;
  color: var(--red);
  line-height: 1.45;
}

.ok {
  margin-bottom: 14px;
  padding: 11px 13px;
  border: 1px solid #bfe3cc;
  border-radius: 6px;
  background: #f2fbf5;
  color: var(--green);
  line-height: 1.45;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 24, 40, 0.42);
}

.modal {
  width: min(620px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  padding: 20px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
}

.import-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 18px;
}

.import-layout.single {
  grid-template-columns: minmax(0, 760px);
}

.hint-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.audit-change {
  max-width: 360px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #334155;
  font-size: 12px;
}

@media (max-width: 820px) {
  .topbar {
    position: static;
    flex-direction: column;
    align-items: stretch;
    padding: 14px;
  }

  .brand,
  .top-actions {
    min-width: 0;
  }

  .nav {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .page {
    padding: 18px 14px 32px;
  }

  .page-title,
  .toolbar,
  .toolbar-left,
  .toolbar-right {
    align-items: stretch;
    flex-direction: column;
  }

  .permission-grid,
  .import-layout {
    grid-template-columns: 1fr;
  }

  .search-input {
    min-width: 0;
  }
}
