
:root {
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #17202a;
  background: #f5f7f9;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: #f5f7f9;
}

[hidden] { display: none !important; }

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

.login-panel {
  display: grid;
  width: min(390px, 100%);
  gap: 16px;
  border: 1px solid #dfe4e8;
  border-radius: 8px;
  padding: 28px;
  background: #fff;
  box-shadow: 0 18px 50px rgb(20 30 40 / 8%);
}

.login-panel .subtitle { margin: -8px 0 4px; }
.login-button { width: 100%; margin-top: 2px; }

button, input, select { font: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

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

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

.eyebrow {
  margin: 0 0 8px;
  color: #66707a;
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 0;
  color: #111820;
  font-size: 30px;
  line-height: 1.2;
}

.subtitle {
  margin: 8px 0 0;
  color: #66707a;
  font-size: 14px;
}

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

.refresh-button, .secondary-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 6px;
  padding: 0 15px;
  cursor: pointer;
  text-decoration: none;
}

.refresh-button {
  border: 1px solid #151b22;
  color: #fff;
  background: #151b22;
}

.secondary-button { border: 1px solid #d5dbe0; color: #28323c; background: #fff; }
.secondary-button:hover { border-color: #aeb7bf; background: #f8f9fa; }

.refresh-button:hover { background: #29313a; }
.refresh-button:disabled { cursor: wait; opacity: .58; }
.refresh-button.is-loading .refresh-icon { animation: spin .8s linear infinite; }

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid #dfe4e8;
  border-radius: 8px;
  margin-bottom: 16px;
  background: #fff;
}

.summary > div {
  min-width: 0;
  padding: 18px 20px;
  border-right: 1px solid #e8ecef;
}

.summary > div:last-child { border-right: 0; }
.summary span { display: block; color: #707983; font-size: 12px; }
.summary strong { display: block; margin-top: 6px; font-size: 23px; }

.workspace {
  border: 1px solid #dfe4e8;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #e8ecef;
}

.search-field {
  display: flex;
  width: min(420px, 100%);
  min-height: 40px;
  align-items: center;
  gap: 9px;
  border: 1px solid #d5dbe0;
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
}

.search-field:focus-within { border-color: #4c7a68; box-shadow: 0 0 0 3px #e4f0eb; }
.search-field input { width: 100%; border: 0; outline: 0; color: #17202a; background: transparent; }

.filter-field { display: flex; align-items: center; gap: 8px; color: #66707a; font-size: 13px; }
.filter-field select { min-height: 40px; border: 1px solid #d5dbe0; border-radius: 6px; padding: 0 34px 0 11px; color: #17202a; background: #fff; }

.page-message { min-height: 0; margin: 0; padding: 0 16px; color: #b42318; font-size: 13px; }
.page-message:not(:empty) { padding-top: 12px; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td { padding: 14px 16px; border-bottom: 1px solid #edf0f2; text-align: left; vertical-align: middle; }
th { color: #6b747d; background: #fafbfc; font-size: 12px; font-weight: 600; }
td { color: #28323c; font-size: 13px; }
th:first-child { width: 28%; }
th:nth-child(2) { width: 12%; }
th:nth-child(3) { width: 15%; }
th:nth-child(4) { width: 17%; }
th:nth-child(5) { width: 13%; }
th:last-child { width: 15%; }
th:last-child { width: 48px; }
tbody tr:last-child td { border-bottom: 0; }

.site-cell strong, .user-cell strong { display: block; overflow: hidden; color: #17202a; text-overflow: ellipsis; white-space: nowrap; }
.site-cell span, .cell-note { display: block; margin-top: 4px; overflow: hidden; color: #7b848d; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  color: #49545e;
  background: #eef1f3;
  font-size: 11px;
  font-weight: 600;
}

.badge.available, .badge.linked { color: #17613f; background: #e4f3eb; }
.badge.error { color: #9d2a23; background: #fbe9e7; }
.badge.stale { color: #825b09; background: #fbf0d5; }
.badge.unlinked { color: #5c6470; background: #eceff2; }
.balance { color: #17613f; font-size: 14px; font-weight: 700; }
.row-action { width: 32px; height: 32px; border: 0; border-radius: 5px; color: #59636d; background: transparent; cursor: pointer; }
.row-action:hover { color: #17202a; background: #eef1f3; }

.empty-state { padding: 54px 20px; text-align: center; }
.empty-state strong, .empty-state span { display: block; }
.empty-state span { margin-top: 6px; color: #7b848d; font-size: 13px; }

.account-dialog {
  width: min(620px, calc(100% - 24px));
  max-height: calc(100vh - 32px);
  border: 1px solid #dfe4e8;
  border-radius: 8px;
  padding: 0;
  color: #17202a;
  background: #fff;
  box-shadow: 0 24px 70px rgb(20 30 40 / 20%);
}
.account-dialog::backdrop { background: rgb(23 32 42 / 42%); }
.account-dialog form { padding: 22px; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.dialog-header h2 { margin: 0; font-size: 21px; }
.icon-button { width: 34px; height: 34px; border: 0; border-radius: 5px; color: #66707a; background: transparent; font-size: 23px; cursor: pointer; }
.icon-button:hover { background: #eef1f3; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; color: #49545e; font-size: 12px; font-weight: 600; }
.field-wide { grid-column: 1 / -1; }
.field small { color: #8a929a; font-weight: 400; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid #d5dbe0; border-radius: 6px; padding: 9px 10px; outline: 0; color: #17202a; background: #fff; font-size: 13px; font-weight: 400; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #4c7a68; box-shadow: 0 0 0 3px #e4f0eb; }
.form-message { min-height: 18px; margin: 12px 0 0; color: #b42318; font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .shell { width: min(100% - 24px, 620px); padding: 24px 0 36px; }
  .page-header { align-items: flex-start; }
  h1 { font-size: 25px; }
  .header-actions .secondary-button span:last-child, .header-actions .refresh-button span:last-child { display: none; }
  .header-actions .secondary-button, .header-actions .refresh-button { width: 40px; padding: 0; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary > div:nth-child(2) { border-right: 0; }
  .summary > div:nth-child(-n+2) { border-bottom: 1px solid #e8ecef; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .filter-field { justify-content: space-between; }
  .filter-field select { flex: 1; }
  table, tbody { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  tr[data-account-row] { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 16px; padding: 15px 16px; border-bottom: 1px solid #edf0f2; }
  tr[data-account-row]:last-child { border-bottom: 0; }
  td { display: block; min-width: 0; padding: 0; border: 0; }
  td.site-cell { grid-column: 1; }
  td.type-cell { grid-column: 2; grid-row: 1; text-align: right; }
  td.user-cell, td.balance-cell, td.link-cell, td.time-cell { font-size: 12px; }
  td.user-cell::before { content: "用户  "; color: #8a929a; }
  td.user-cell strong { display: inline; }
  td.balance-cell { grid-column: 2; grid-row: 2; text-align: right; }
  td.link-cell { grid-column: 1; grid-row: 3; }
  td.time-cell { grid-column: 2; grid-row: 3; color: #7b848d; text-align: right; }
  td.action-cell { grid-column: 2; grid-row: 1; align-self: end; margin-right: -7px; }
  td.type-cell { margin-right: 34px; }
  .account-dialog form { padding: 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
}
