:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --panel: #ffffff;
  --line: #dbe2e7;
  --line-strong: #c3ced6;
  --text: #17211c;
  --muted: #5f6d68;
  --green: #197a55;
  --green-dark: #145f43;
  --amber: #a46710;
  --red: #b33b32;
  --soft: #f7f9fb;
  --shadow: 0 18px 40px rgba(30, 45, 38, 0.1);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

a {
  color: var(--green);
  text-decoration: none;
}

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

.auth-shell {
  width: min(100%, 760px);
}

.auth-panel {
  width: min(100%, 420px);
  margin: 0 auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-panel.wide {
  width: min(100%, 760px);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.auth-brand.compact {
  margin-bottom: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #18231f;
  color: #f4f8f5;
  font-weight: 800;
}

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

.auth-brand strong {
  font-size: 18px;
}

.auth-brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.auth-form {
  display: grid;
  gap: 14px;
}

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

.auth-form label {
  display: grid;
  gap: 7px;
}

.auth-form span {
  color: var(--muted);
  font-size: 13px;
}

.auth-form input,
.admin-page select,
.admin-page input[type="search"] {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.auth-form input:focus,
.admin-page select:focus,
.admin-page input[type="search"]:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(25, 122, 85, 0.13);
}

.full {
  grid-column: 1 / -1;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.form-message.error {
  color: var(--red);
}

.form-message.success {
  color: var(--green);
}

.primary-button,
.secondary-button {
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
}

.primary-button {
  border: 0;
  background: var(--green);
  color: #fff;
  font-weight: 800;
}

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

.secondary-button {
  display: inline-grid;
  place-items: center;
  min-width: 86px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
}

.auth-footer {
  margin-top: 18px;
  display: flex;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.empty-auth-state {
  margin: 0 0 18px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  line-height: 1.6;
}

.admin-page {
  min-height: 100vh;
}

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

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

.admin-layout {
  width: min(100%, 1280px);
  margin: 0 auto;
  padding: 18px 20px 28px;
}

.admin-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.admin-summary article,
.admin-panel,
.user-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.admin-summary article {
  min-height: 86px;
  padding: 14px;
}

.admin-summary span,
.user-meta,
.permission-group span,
.admin-panel-header p {
  color: var(--muted);
  font-size: 13px;
}

.admin-summary strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.admin-panel {
  padding: 16px;
}

.admin-panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.admin-panel h1 {
  margin: 0;
  font-size: 22px;
}

.admin-panel-header p {
  margin: 5px 0 0;
}

.users-list {
  display: grid;
  gap: 10px;
}

.account-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(128px, 0.34fr) minmax(128px, 0.34fr) minmax(150px, 0.4fr) auto auto;
  gap: 10px;
  align-items: end;
  margin: 12px 0;
}

.account-toolbar[hidden] {
  display: none;
}

.account-toolbar label {
  display: grid;
  gap: 6px;
}

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

.account-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  align-self: center;
}

.account-list {
  display: grid;
  gap: 10px;
}

.account-row {
  min-height: 82px;
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) minmax(120px, 0.55fr) minmax(130px, 0.55fr) minmax(180px, 0.75fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.account-cell {
  display: grid;
  gap: 5px;
  min-width: 0;
}

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

.account-cell strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.account-cell small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.user-card {
  padding: 14px;
}

.detail-mode {
  gap: 0;
}

.detail-breadcrumb {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.detail-breadcrumb strong {
  color: var(--text);
}

.user-card-header {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(160px, 0.7fr) minmax(160px, 0.7fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.user-title strong,
.user-title small {
  display: block;
}

.user-title small {
  margin-top: 4px;
}

.user-meta {
  line-height: 1.55;
}

.role-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
}

.detail-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.detail-summary span {
  display: grid;
  gap: 4px;
  min-height: 52px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
}

.detail-summary strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 14px;
}

.permission-toolbar {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--green);
  cursor: pointer;
  font-weight: 800;
}

.link-button:disabled {
  color: var(--muted);
  cursor: default;
}

.role-toggle input,
.permission-item input,
.group-check input,
.permission-toolbar input {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
}

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

.permission-group {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.group-check,
.permission-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.group-check {
  margin-bottom: 8px;
  font-weight: 800;
}

.group-check span {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.permission-items {
  display: grid;
  gap: 7px;
}

.permission-item {
  color: var(--text);
  font-size: 13px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: #e4eef9;
  color: #2d65a3;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.pending {
  background: #fbefd8;
  color: var(--amber);
}

.status-pill.active {
  background: #e0f2e9;
  color: var(--green);
}

.status-pill.disabled,
.status-pill.rejected {
  background: #f8dfdd;
  color: var(--red);
}

@media (max-width: 860px) {
  .auth-form.two-column,
  .admin-summary,
  .account-toolbar,
  .permission-grid,
  .detail-summary,
  .user-card-header,
  .account-row {
    grid-template-columns: 1fr;
  }

  .admin-topbar {
    height: auto;
    align-items: flex-start;
    padding: 14px;
    flex-direction: column;
  }
}
