:root {
  color-scheme: light;
  --bg: #f3f5f6;
  --surface: #ffffff;
  --text: #18201d;
  --muted: #68736f;
  --border: #d8dfdc;
  --accent: #167d56;
  --accent-hover: #0f6847;
  --accent-soft: #e6f4ee;
  --info: #2764a7;
  --danger: #b4232f;
  --danger-soft: #fff0f1;
  --shadow: 0 12px 36px rgba(24, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

.topbar {
  min-height: 64px;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 700;
}

.brand-link {
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 5px;
  background: var(--text);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
}

.service-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

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

.language-select {
  width: 108px;
  height: 36px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background-color: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  outline: none;
}

.language-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.admin-entry {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.admin-entry:hover {
  border-color: #aeb9b4;
  background: #f7f9f8;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a6afac;
}

.status-dot.online {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.status-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.workspace {
  width: min(960px, calc(100% - 40px));
  margin: 56px auto;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 24px;
  align-items: stretch;
}

.query-panel,
.result-panel {
  min-width: 0;
  min-height: 360px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.query-panel {
  padding: 36px;
  display: flex;
  flex-direction: column;
}

.section-heading {
  margin-bottom: 44px;
}

.section-label {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 26px;
  line-height: 1.25;
}

h2 {
  margin-bottom: 0;
  font-size: 15px;
}

.query-panel form {
  margin-top: auto;
  margin-bottom: auto;
}

label {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.query-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px;
  gap: 10px;
}

input {
  width: 100%;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fbfcfc;
  color: var(--text);
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

button {
  height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

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

.button-secondary {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.button-secondary:hover {
  border-color: #aeb9b4;
  background: #f7f9f8;
}

.button-quiet {
  height: auto;
  padding: 7px 9px;
  background: transparent;
  color: var(--info);
  font-size: 13px;
}

.button-quiet:hover {
  background: #edf4fb;
}

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

.button-danger:hover {
  background: #921923;
}

.button-compact {
  width: auto;
  height: 36px;
  padding: 0 13px;
  font-size: 13px;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.input-message {
  min-height: 20px;
  margin: 7px 0 0;
  color: var(--danger);
  font-size: 12px;
}

.result-panel {
  padding: 0;
  overflow: hidden;
}

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

.result-state {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  min-height: 300px;
  padding: 32px;
  display: grid;
  place-content: center;
  justify-items: center;
  color: var(--muted);
  text-align: center;
}

.empty-symbol {
  width: 56px;
  height: 56px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #f8faf9;
  color: var(--info);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
}

.empty-state p {
  margin-bottom: 0;
  font-size: 13px;
}

.result-data {
  margin: 0;
  padding: 30px;
}

.result-data div {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.result-data div:last-child {
  border-bottom: 0;
}

.result-data dt {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.result-data dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 19px;
  font-weight: 700;
}

#result-tag {
  color: var(--accent);
  font-size: 24px;
}

.error-state {
  margin: 30px;
  padding: 18px;
  border: 1px solid #f1c4c8;
  border-radius: 6px;
  background: var(--danger-soft);
  color: var(--danger);
}

.error-state strong {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
}

.error-state p {
  margin-bottom: 0;
  font-size: 13px;
  line-height: 1.55;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.account-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-name {
  max-width: 240px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.login-view {
  width: min(440px, calc(100% - 32px));
  margin: 72px auto;
}

.login-panel {
  padding: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin-bottom: 32px;
}

.login-panel label:not(:first-of-type) {
  margin-top: 18px;
}

.login-panel button[type="submit"] {
  width: 100%;
  margin-top: 8px;
}

.form-message {
  min-height: 20px;
  margin: 8px 0;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
}

.admin-workspace {
  width: min(1180px, calc(100% - 48px));
  margin: 44px auto 72px;
}

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

.admin-toolbar {
  min-height: 70px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-form {
  width: min(520px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.notice {
  padding: 11px 16px;
  border: 1px solid #f1c4c8;
  border-bottom: 0;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}

.notice.success {
  border-color: #b9decf;
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.table-shell {
  position: relative;
  min-height: 220px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  background: var(--surface);
}

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

th,
td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f8faf9;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

td {
  overflow-wrap: anywhere;
  font-size: 14px;
}

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

tbody tr:hover {
  background: #fbfcfc;
}

.chipid-cell {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-weight: 700;
}

.actions-column,
.row-actions {
  width: 150px;
  text-align: right;
}

.row-actions {
  white-space: nowrap;
}

.button-table {
  margin-left: 4px;
}

.danger-text {
  color: var(--danger);
}

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

.table-state {
  min-height: 164px;
  padding: 48px 20px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.pagination {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.pagination p,
.page-indicator {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.pagination-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

dialog {
  width: min(460px, calc(100% - 28px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 72px rgba(24, 32, 29, 0.2);
}

dialog::backdrop {
  background: rgba(24, 32, 29, 0.42);
}

.dialog-form {
  padding: 24px;
}

.dialog-form label:not(:first-of-type) {
  margin-top: 16px;
}

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

.dialog-close {
  width: 34px;
  height: 34px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: 25px;
  font-weight: 400;
  line-height: 1;
}

.dialog-close:hover {
  background: #f1f4f3;
  color: var(--text);
}

.dialog-copy {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.confirm-chipid {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f8faf9;
  overflow-wrap: anywhere;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  font-weight: 700;
}

.dialog-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}

@media (max-width: 720px) {
  .topbar {
    min-height: 58px;
    padding: 0 18px;
  }

  .service-status span:last-child {
    display: none;
  }

  .topbar-actions {
    gap: 10px;
  }

  .language-select {
    width: 90px;
  }

  .workspace {
    width: min(100% - 24px, 520px);
    margin: 24px auto;
    grid-template-columns: 1fr;
  }

  .query-panel,
  .result-panel {
    min-height: 300px;
  }

  .query-panel {
    padding: 26px 22px;
  }

  .section-heading {
    margin-bottom: 30px;
  }

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

  .query-row button {
    width: 100%;
  }

  .empty-state {
    min-height: 240px;
  }

  .admin-workspace {
    width: min(100% - 24px, 680px);
    margin-top: 28px;
  }

  .admin-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-heading > button {
    width: 100%;
  }

  .admin-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search-form {
    width: 100%;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
  }

  thead {
    display: none;
  }

  tbody tr {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
  }

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

  td {
    padding: 6px 0;
    border: 0;
  }

  td:nth-child(2)::before {
    content: "Tag";
    margin-right: 9px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
  }

  td:nth-child(3)::before {
    content: "最后操作人";
    margin-right: 9px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
  }

  .row-actions {
    width: 100%;
    padding-top: 10px;
    text-align: left;
  }

  .button-table {
    margin-right: 4px;
    margin-left: 0;
  }

  .pagination {
    padding: 14px 0;
    align-items: stretch;
    flex-direction: column;
  }

  .pagination-actions {
    justify-content: space-between;
  }
}

@media (max-width: 460px) {
  .public-page .brand > span:last-child {
    display: none;
  }

  .public-page .topbar {
    gap: 12px;
  }

  .public-page .topbar-actions {
    gap: 8px;
  }

  .public-page .language-select {
    width: 84px;
    padding-right: 22px;
  }

  .public-page .admin-entry {
    padding: 0 9px;
    font-size: 12px;
  }

  .account-name {
    display: none;
  }

  .login-view {
    margin-top: 28px;
  }

  .login-panel {
    padding: 26px 22px;
  }

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

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

  .dialog-actions button {
    flex: 1;
  }
}
