:root {
  color: #202124;
  background: #f5f6f7;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
  --brand: #d71920;
  --brand-dark: #a90f15;
  --ink: #202124;
  --muted: #697077;
  --line: #d9dde1;
  --surface: #ffffff;
  --soft: #f1f3f4;
  --success: #147d64;
  --warning: #a85b00;
  --danger: #bd1e27;
  --focus: #1167b1;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #f5f6f7;
  color: var(--ink);
}

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

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

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(17, 103, 177, 0.3);
  outline-offset: 2px;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, #d71920 0, #d71920 34%, #f5f6f7 34%, #f5f6f7 100%);
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(360px, 1.2fr);
  width: min(880px, 100%);
  min-height: 520px;
  overflow: hidden;
  border: 1px solid rgba(32, 33, 36, 0.12);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(32, 33, 36, 0.16);
}

.login-brand {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 42px 36px;
  background: var(--brand);
  color: #ffffff;
}

.login-brand img {
  width: min(190px, 100%);
  max-height: 74px;
  object-fit: contain;
  object-position: left center;
}

.login-brand h1 {
  margin: auto 0 10px;
  font-size: 30px;
  line-height: 1.25;
  letter-spacing: 0;
}

.login-brand p {
  margin: 0;
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
}

.login-form-area {
  display: flex;
  align-items: center;
  padding: 48px clamp(32px, 7vw, 72px);
}

.login-form {
  width: 100%;
}

.login-form h2 {
  margin: 0 0 8px;
  font-size: 24px;
  letter-spacing: 0;
}

.login-form > p {
  margin: 0 0 30px;
  color: var(--muted);
  font-size: 14px;
}

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

.field label {
  color: #3c4043;
  font-size: 13px;
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #c7ccd1;
  border-radius: 5px;
  background: #ffffff;
  color: var(--ink);
}

.field input:hover,
.field select:hover {
  border-color: #8b9299;
}

.field input:focus,
.field select:focus {
  border-color: var(--focus);
}

.password-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.password-field input {
  border-radius: 5px 0 0 5px;
}

.credential-username {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.password-toggle {
  min-width: 58px;
  border: 1px solid #c7ccd1;
  border-left: 0;
  border-radius: 0 5px 5px 0;
  background: var(--soft);
  color: #3c4043;
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

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

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

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

.button-secondary {
  border-color: #bcc2c8;
  background: #ffffff;
  color: #303438;
}

.button-secondary:hover:not(:disabled) {
  background: var(--soft);
}

.button-danger {
  border-color: #e6b3b7;
  background: #ffffff;
  color: var(--danger);
}

.button-danger:hover:not(:disabled) {
  background: #fff1f2;
}

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

.login-submit {
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
}

.form-message {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 10px clamp(18px, 4vw, 54px);
  border-bottom: 4px solid var(--brand);
  background: #ffffff;
}

.topbar-brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 16px;
}

.topbar-brand img {
  width: 128px;
  height: 44px;
  object-fit: contain;
}

.topbar-title {
  min-width: 0;
}

.topbar-title h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: 0;
}

.topbar-title p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-main {
  width: min(1220px, calc(100% - 36px));
  margin: 28px auto 48px;
}

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

.page-heading h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.page-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.account-layout {
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

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

.panel-header {
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-header h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-body {
  padding: 20px;
}

.generated-password {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.generated-password input {
  border-radius: 5px 0 0 5px;
}

.generated-password .button {
  border-radius: 0 5px 5px 0;
}

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

.account-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.account-table th,
.account-table td {
  padding: 13px 14px;
  border-bottom: 1px solid #e7eaed;
  text-align: left;
  vertical-align: middle;
}

.account-table th {
  background: #f8f9fa;
  color: #50565c;
  font-size: 12px;
  font-weight: 700;
}

.account-table td {
  font-size: 13px;
}

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

.account-table .col-user {
  width: 23%;
}

.account-table .col-role,
.account-table .col-status {
  width: 15%;
}

.account-table .col-login {
  width: 21%;
}

.account-table .col-actions {
  width: 26%;
}

.username {
  display: block;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.self-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

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

.badge-admin {
  background: #fff0f1;
  color: #aa1720;
}

.badge-operator {
  background: #eaf3fb;
  color: #215e8d;
}

.status-active {
  color: var(--success);
  font-weight: 700;
}

.status-disabled {
  color: var(--muted);
  font-weight: 700;
}

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

.password-panel {
  margin-top: 22px;
}

.password-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.password-form .field {
  margin: 0;
}

.force-password {
  margin-bottom: 18px;
  padding: 12px 15px;
  border-left: 4px solid var(--warning);
  background: #fff7e8;
  color: #764000;
  font-size: 13px;
}

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

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 44px));
  padding: 12px 16px;
  border-radius: 6px;
  background: #25292d;
  color: #ffffff;
  box-shadow: 0 8px 28px rgba(32, 33, 36, 0.24);
  font-size: 13px;
}

.toast.error {
  background: #9f1820;
}

.toast[hidden] {
  display: none;
}

dialog {
  width: min(460px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.25);
}

dialog::backdrop {
  background: rgba(20, 22, 24, 0.52);
}

.dialog-header,
.dialog-body,
.dialog-actions {
  padding: 18px 20px;
}

.dialog-header {
  border-bottom: 1px solid var(--line);
}

.dialog-header h3 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0;
}

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

.auth-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-controls__user {
  max-width: 150px;
  overflow: hidden;
  color: #555b61;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-controls__link,
.auth-controls__logout {
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 5px;
  background: #ffffff;
  color: #33373b;
  cursor: pointer;
  font: 600 12px/1.3 "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
  text-decoration: none;
}

.auth-controls__link:hover,
.auth-controls__logout:hover {
  background: #f1f3f4;
}

@media (max-width: 800px) {
  .login-page {
    padding: 16px;
    background: #f5f6f7;
  }

  .login-shell {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .login-brand {
    align-items: center;
    flex-direction: row;
    gap: 22px;
    min-height: 170px;
    padding: 26px;
  }

  .login-brand img {
    width: 96px;
    flex: 0 0 96px;
  }

  .login-brand h1 {
    margin: 0 0 6px;
    font-size: 24px;
  }

  .login-form-area {
    padding: 30px 26px 34px;
  }

  .account-layout {
    grid-template-columns: 1fr;
  }

  .password-form {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar-brand img {
    width: 92px;
  }

  .topbar-title p {
    display: none;
  }
}

@media (max-width: 560px) {
  .topbar {
    gap: 12px;
    padding-inline: 12px;
  }

  .topbar-brand {
    gap: 0;
  }

  .topbar-brand img {
    display: none;
  }

  .topbar-actions .button {
    padding-inline: 10px;
  }

  .page-main {
    width: calc(100% - 24px);
    margin-top: 18px;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .account-table,
  .account-table tbody,
  .account-table tr,
  .account-table td {
    display: block;
    width: 100%;
  }

  .account-table thead {
    display: none;
  }

  .account-table tr {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
  }

  .account-table td {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    padding: 7px 0;
    border: 0;
  }

  .account-table td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 12px;
    font-weight: 700;
  }

  .row-actions {
    margin-top: 2px;
  }

  .auth-controls__user {
    display: none;
  }
}
