:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei UI", sans-serif;
  color: #20252b;
  background: #f4f6f8;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  display: flex;
  flex-direction: column;
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #ffffff;
  border-bottom: 1px solid #dfe3e8;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 40px));
  min-height: 64px;
  margin: 0 auto;
}

.brand {
  display: flex;
  min-width: 0;
  gap: 10px;
  align-items: center;
  color: #20252b;
  font-weight: 650;
  font-size: 18px;
  white-space: nowrap;
  text-decoration: none;
}

.brand::before {
  flex: 0 0 auto;
  width: 4px;
  height: 20px;
  background: #245f9e;
  border-radius: 2px;
  content: "";
}

.header-actions,
.account {
  display: flex;
  gap: 10px;
  align-items: center;
}

.header-actions {
  flex: 0 0 auto;
}

.header-toggle {
  display: none;
}

.topbar .button,
.topbar .role-badge {
  flex-shrink: 0;
  white-space: nowrap;
}

.role-badge {
  padding: 3px 7px;
  color: #555555;
  font-size: 12px;
  background: #f2f2f2;
  border: 1px solid #dddddd;
  border-radius: 3px;
}

.button {
  min-height: 38px;
  padding: 8px 16px;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 4px;
  transition: background-color 120ms ease, border-color 120ms ease;
}

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

.button.primary {
  color: #ffffff;
  background: #245f9e;
  border-color: #245f9e;
}

.button.primary:hover:not(:disabled) {
  background: #1d4f84;
}

.button.secondary {
  color: #333333;
  background: #ffffff;
  border-color: #cccccc;
}

.button.secondary:hover:not(:disabled) {
  background: #f4f4f4;
}

.button.compact {
  min-height: 32px;
  padding: 5px 11px;
  font-size: 14px;
}

.button.wide {
  width: 100%;
}

main {
  flex: 1;
  width: min(1180px, calc(100% - 40px));
  margin: 24px auto 40px;
}

.workspace-nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  margin-bottom: 12px;
  border-bottom: 1px solid #d5dbe1;
}

.nav-item {
  padding: 10px 14px;
  color: #555555;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  transition: color 120ms ease, border-color 120ms ease;
}

.nav-item:hover,
.nav-item.active {
  color: #245f9e;
}

.nav-item.active {
  border-bottom-color: #245f9e;
}

.workspace {
  min-width: 0;
  padding: 24px;
  background: #ffffff;
  border: 1px solid #dfe3e8;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(25, 39, 52, 0.04);
}

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

.section-heading h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.3;
}

.search-box {
  display: flex;
  gap: 10px;
  padding: 14px;
  background: #f7f9fb;
  border: 1px solid #e2e7eb;
  border-radius: 4px;
}

.search-box input {
  flex: 1;
  min-width: 0;
}

.search-box .button {
  min-width: 96px;
}

.declaration-search {
  margin-bottom: 16px;
}

.audit-filter {
  margin-bottom: 16px;
}

.audit-filter select {
  min-width: 190px;
}

.pagination {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 16px;
  color: #555555;
  font-size: 14px;
}

input,
select {
  padding: 9px 11px;
  color: #222222;
  background: #ffffff;
  border: 1px solid #bfbfbf;
  border-radius: 4px;
  outline: none;
}

input:focus,
select:focus {
  border-color: #245f9e;
  box-shadow: 0 0 0 2px rgba(36, 95, 158, 0.12);
}

.empty-state {
  margin: 0;
  padding: 48px 16px;
  color: #777777;
  text-align: center;
}

.muted {
  color: #666666;
  line-height: 1.6;
}

.table-card {
  max-width: 100%;
  overflow: auto;
  border: 1px solid #dfe3e8;
  border-radius: 4px;
}

table {
  width: 100%;
  white-space: nowrap;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  font-size: 14px;
  text-align: left;
  border-bottom: 1px solid #e5e5e5;
}

th {
  color: #444444;
  font-weight: 600;
  background: #f6f8fa;
}

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

tbody tr:hover {
  background: #f8fafc;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(36, 95, 158, 0.45);
  outline-offset: 2px;
}

.link-button {
  padding: 0;
  color: #245f9e;
  font-weight: 600;
  background: transparent;
  border: 0;
}

.pdf-link {
  color: #245f9e;
  font-weight: 600;
  text-decoration: none;
}

.link-button:hover,
.pdf-link:hover {
  text-decoration: underline;
}

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

.link-button.danger {
  color: #a12622;
}

.token-remark {
  width: 210px;
}

.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.inline-form-card {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(150px, 220px) minmax(170px, 240px) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
  padding: 16px;
  background: #fafbfc;
  border: 1px solid #dfe3e8;
  border-radius: 4px;
}

.inline-form-card p {
  margin: 4px 0 0;
  color: #666666;
}

.session-cell {
  min-width: 140px;
}

.session-detail-row td {
  padding: 0;
  white-space: normal;
  background: #f8fafc;
}

.session-detail-row:hover {
  background: transparent;
}

.session-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0 20px;
  padding: 10px 16px 14px;
}

.session-item {
  display: grid;
  gap: 2px;
  padding: 7px 0;
}

.session-item + .session-item {
  border-top: 1px solid #e5e5e5;
}

.session-item span {
  max-width: 430px;
  overflow: hidden;
  color: #666666;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-cell {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-label {
  display: inline-block;
  padding: 3px 7px;
  font-size: 12px;
  border: 1px solid #cccccc;
  border-radius: 3px;
}

.status-label.pending {
  color: #755b00;
  background: #fff9dd;
  border-color: #dbc56d;
}

.status-label.active {
  color: #176339;
  background: #edf8f1;
  border-color: #8fc6a6;
}

.status-label.disabled {
  color: #666666;
  background: #f2f2f2;
}

.setting-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding: 16px;
  background: #fafbfc;
  border: 1px solid #dfe3e8;
  border-radius: 4px;
}

.setting-card p {
  margin: 4px 0 0;
  color: #666666;
}

.setting-control {
  display: flex;
  gap: 10px;
  align-items: center;
}

.setting-control input {
  width: min(320px, 42vw);
}

.setting-control .button {
  flex-shrink: 0;
  white-space: nowrap;
}

.declaration-visibility-setting {
  align-items: stretch;
  flex-direction: column;
}

.declaration-visibility-setting .setting-control {
  width: 100%;
}

.declaration-visibility-setting .setting-control input {
  flex: 1;
  width: auto;
  min-width: 240px;
}

.site-footer {
  padding: 0 20px 24px;
  color: #666666;
  font-size: 14px;
  text-align: center;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  color: #245f9e;
  text-decoration: underline;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  display: block;
  width: 44px;
  height: 24px;
  padding: 2px;
  background: #aaaaaa;
  border-radius: 12px;
}

.switch span::after {
  display: block;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 50%;
  content: "";
}

.switch input:checked + span {
  background: #245f9e;
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

dialog {
  max-height: 82vh;
  padding: 0;
  background: #ffffff;
  border: 1px solid #cccccc;
  border-radius: 5px;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.auth-dialog {
  width: min(420px, calc(100% - 28px));
}

.detail-dialog {
  width: min(850px, calc(100% - 28px));
}

.pdf-dialog {
  width: min(1100px, calc(100% - 28px));
  height: min(88vh, 920px);
  max-height: 88vh;
}

.pdf-dialog[open] {
  display: flex;
  flex-direction: column;
}

.pdf-frame {
  flex: 1;
  width: 100%;
  min-height: 360px;
  background: #eeeeee;
  border: 0;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 12px 18px;
  border-top: 1px solid #dddddd;
}

.dialog-actions .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #dddddd;
}

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

.icon-button {
  padding: 0 4px;
  color: #555555;
  font-size: 26px;
  line-height: 1;
  background: transparent;
  border: 0;
}

.auth-content {
  padding: 20px;
}

.tabs {
  display: flex;
  margin-bottom: 20px;
  border-bottom: 1px solid #dddddd;
}

.tab {
  flex: 1;
  padding: 9px;
  color: #666666;
  font-weight: 600;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
}

.tab.active {
  color: #245f9e;
  border-bottom-color: #245f9e;
}

.auth-content label {
  display: grid;
  gap: 6px;
  margin: 14px 0;
  color: #333333;
  font-size: 14px;
}

.form-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: #a12622;
  font-size: 14px;
}

.detail-dialog pre {
  max-height: 65vh;
  margin: 0;
  padding: 18px;
  overflow: auto;
  font: 13px/1.6 Consolas, monospace;
  white-space: pre-wrap;
  background: #f7f7f7;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: 420px;
  padding: 11px 15px;
  color: #ffffff;
  background: #333333;
  border-radius: 4px;
}

.toast.error {
  background: #a12622;
}

@media (max-width: 700px) {
  .topbar-inner,
  main {
    width: calc(100% - 24px);
  }

  .topbar-inner {
    flex-wrap: wrap;
    gap: 8px;
    min-height: 56px;
    padding: 9px 0;
  }

  .brand {
    gap: 8px;
    overflow: hidden;
    font-size: 16px;
    text-overflow: ellipsis;
  }

  .header-toggle {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    min-height: 36px;
    padding: 6px 10px;
    color: #333333;
    font: inherit;
    font-size: 14px;
    background: #ffffff;
    border: 1px solid #cccccc;
    border-radius: 4px;
  }

  .header-toggle:hover {
    background: #f4f4f4;
  }

  .header-toggle-icon {
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 120ms ease;
  }

  .header-expanded .header-toggle-icon {
    transform: translateY(2px) rotate(225deg);
  }

  .header-actions {
    display: none;
    flex: 1 0 100%;
    justify-content: flex-end;
    width: 100%;
    padding-top: 9px;
    border-top: 1px solid #e5e8eb;
  }

  .header-expanded .header-actions {
    display: flex;
  }

  .account {
    flex-wrap: wrap;
    justify-content: flex-end;
    width: 100%;
    gap: 8px;
  }

  .account [data-current-user] {
    flex: 1 0 100%;
    overflow-wrap: anywhere;
    font-weight: 600;
    text-align: right;
  }

  .account [data-current-user]::before {
    color: #666666;
    font-weight: 400;
    content: "当前用户：";
  }

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

  .workspace {
    padding: 18px;
  }

  .section-heading {
    flex-direction: column;
  }

  .search-box {
    flex-direction: column;
  }

  .search-box .button {
    width: 100%;
  }

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

  .icp-setting,
  .declaration-visibility-setting,
  .setting-control {
    align-items: stretch;
    flex-direction: column;
  }

  .setting-control input {
    width: 100%;
    min-width: 0;
  }
}
