:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-muted: #f7f8fa;
  --line: #e3e7ec;
  --line-strong: #cdd3dc;
  --text: #172033;
  --muted: #667085;
  --accent: #2f6fed;
  --accent-hover: #255fdb;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --success: #067647;
  --success-soft: #ecfdf3;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-variant-numeric: tabular-nums;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

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

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
}

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

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

.login-shell {
  width: min(400px, 100%);
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 24px;
  font-size: 24px;
  font-weight: 700;
}

.brand-mark {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-size: 20px;
}

.auth-panel {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(16, 24, 40, 0.08);
}

.auth-panel h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.auth-panel > p {
  margin: 8px 0 24px;
  color: var(--muted);
  font-size: 14px;
}

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

.field {
  display: grid;
  gap: 7px;
}

.field > span,
.field label {
  color: #344054;
  font-size: 13px;
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.13);
}

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

.primary-button,
.secondary-button,
.danger-button,
.text-button {
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 600;
}

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

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

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

.secondary-button:hover,
.text-button:hover {
  background: var(--surface-muted);
}

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

.danger-button:hover {
  background: var(--danger-soft);
}

.text-button {
  border-color: transparent;
  color: var(--muted);
  background: transparent;
}

.form-error,
.form-success,
.notice {
  display: none;
  margin: 0;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.45;
}

.form-error.visible {
  display: block;
  color: var(--danger);
  background: var(--danger-soft);
}

.form-success.visible {
  display: block;
  color: var(--success);
  background: var(--success-soft);
}

.notice.visible {
  display: block;
  color: #175cd3;
  background: #eff8ff;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 62px;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
}

.app-brand .brand-mark {
  width: 30px;
  height: 30px;
  font-size: 17px;
}

.header-title {
  padding-left: 16px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.header-user {
  margin-right: 8px;
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  width: min(1180px, calc(100% - 40px));
  margin: 28px auto 56px;
}

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

.workspace-heading h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.workspace-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.content-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.panel-heading {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}

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

.panel-body {
  padding: 20px;
}

.account-layout {
  display: grid;
  grid-template-columns: minmax(0, 520px) minmax(240px, 1fr);
  gap: 16px;
}

.policy-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 2;
}

.admin-grid {
  display: grid;
  gap: 16px;
}

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

.summary-item {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-item strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}

th {
  color: var(--muted);
  background: var(--surface-muted);
  font-size: 12px;
  font-weight: 600;
}

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

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

.row-actions button {
  min-height: 30px;
  padding: 0 9px;
  border: 0;
  border-radius: 5px;
  color: #475467;
  background: transparent;
  font-size: 12px;
}

.row-actions button:hover {
  background: #f2f4f7;
}

.row-actions .delete-action {
  color: var(--danger);
}

.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge.admin {
  color: #175cd3;
  background: #eff8ff;
}

.badge.superadmin {
  color: #6941c6;
  background: #f4f3ff;
}

.badge.designer {
  color: #344054;
  background: #f2f4f7;
}

.badge.active {
  color: var(--success);
  background: var(--success-soft);
}

.badge.inactive {
  color: var(--danger);
  background: var(--danger-soft);
}

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

.empty-tool-state {
  display: grid;
  min-height: 320px;
  place-items: center;
  color: var(--muted);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.tool-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  min-height: 92px;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.tool-card:hover {
  border-color: #98a2b3;
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08);
}

.tool-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
}

.tool-copy {
  min-width: 0;
}

.tool-copy strong,
.tool-copy span {
  display: block;
}

.tool-copy strong {
  color: var(--text);
  font-size: 15px;
}

.tool-copy span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.tool-open {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.full-width-action {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
}

dialog {
  width: min(440px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 24px 64px rgba(16, 24, 40, 0.2);
}

dialog::backdrop {
  background: rgba(16, 24, 40, 0.42);
}

.dialog-heading {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
}

.dialog-heading h2 {
  margin: 0;
  font-size: 17px;
}

.dialog-close {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  font-size: 22px;
}

.dialog-close:hover {
  background: var(--surface-muted);
}

.dialog-body {
  padding: 20px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}

.temporary-password {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 14px;
}

.temporary-password code {
  display: flex;
  min-height: 42px;
  align-items: center;
  overflow: auto;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
  font-size: 15px;
}

@media (max-width: 760px) {
  .app-header {
    padding: 0 16px;
  }

  .header-title,
  .header-user,
  .header-actions > a {
    display: none;
  }

  .app-brand {
    font-size: 16px;
  }

  .header-actions #logout-button {
    min-height: 34px;
    padding: 0 8px;
    white-space: nowrap;
  }

  .workspace {
    width: min(100% - 24px, 1180px);
    margin-top: 18px;
  }

  .workspace-heading,
  .account-layout {
    display: grid;
    grid-template-columns: 1fr;
  }

  .summary-row {
    grid-template-columns: 1fr;
  }

  .auth-panel {
    padding: 22px;
  }
}
