:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #fff;
  --text: #182a35;
  --muted: #647580;
  --border: #dce3e8;
  --accent: #126451;
  --accent-soft: #e7f4ee;
  --danger: #a22b34;
  --warning: #785b18;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/21px system-ui, -apple-system, "PingFang SC", sans-serif;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 64px;
  padding: 10px max(20px, calc((100% - 1160px) / 2));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
header > div { display: flex; align-items: center; gap: 12px; }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: 0; color: var(--accent); }
h1 { margin: 0; font-size: 21px; }
h2 { margin: 0 0 3px; font-size: 23px; line-height: 1.25; }
h3 { margin: 0 0 7px; font-size: 17px; }
h4 { margin: 15px 0 6px; font-size: 15px; }
p { margin: 4px 0 8px; }

main { max-width: 1200px; margin: auto; padding: 18px 20px; }
.intro { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 12px; }
.intro > div { min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

nav {
  display: flex;
  gap: 5px;
  margin-bottom: 12px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
}
button, input, select, textarea { font: inherit; }
button {
  min-height: 38px;
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}
button:hover { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: .5; cursor: wait; }
button.primary, nav button.active { border-color: var(--accent); background: var(--accent); color: #fff; }
button.quiet { background: transparent; }
button.danger { color: var(--danger); }
button.danger:hover { border-color: var(--danger); }

input, textarea, select {
  display: block;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
}
input:focus, textarea:focus, button:focus-visible, select:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=checkbox] { display: inline-block; width: 18px; height: 18px; accent-color: var(--accent); vertical-align: middle; }
label { display: block; margin: 8px 0; font-weight: 600; }
label input, label textarea, label select { margin-top: 4px; }
.inline { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.inline input { margin: 0; }

.panel { padding: 15px 16px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); }
.actions { display: flex; flex-wrap: wrap; gap: 7px; }
.status-strip, .toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.status-strip { padding-bottom: 5px; }
.status-strip strong { display: block; }
.status-strip span { display: block; overflow-wrap: anywhere; }
.hourly-refresh-strip { margin: 8px 0 5px; padding: 10px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); }
.hourly-refresh-strip > div:first-child { min-width: 0; }
.hourly-refresh-strip .actions { flex: 0 0 auto; }
#hourly-refresh-last { margin-top: 2px; }
.hint { padding: 8px 11px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); }
#pool-status:empty { display: none; }
.search { flex: 1; max-width: 300px; margin: 7px 0; }

.table-wrap { width: 100%; margin-top: 7px; overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; }
th { background: var(--bg); color: var(--muted); font-size: 12px; font-weight: 700; }
th, td { padding: 8px 7px; border-bottom: 1px solid var(--border); vertical-align: top; }
td:first-child, th:first-child { width: 40px; }
td .email { font-weight: 600; overflow-wrap: anywhere; }
td small { display: block; max-width: 300px; margin-top: 2px; color: var(--muted); overflow-wrap: anywhere; }
.account-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: 2px; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); font-size: 12px; }
.warn { color: var(--warning); }
.error { color: var(--danger); }
.empty { padding: 34px 18px; text-align: center; }
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 10px; }

.notice { position: sticky; top: 8px; z-index: 2; margin-bottom: 12px; padding: 10px 13px; border: 1px solid var(--border); border-radius: 8px; background: var(--accent-soft); overflow-wrap: anywhere; }
.notice.error { border-color: #e4a4ac; background: #fff0f1; }
#settings-form { max-width: 780px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
hr { margin: 18px 0; border: 0; border-top: 1px solid var(--border); }
.preview-list { max-height: 260px; padding-left: 22px; overflow: auto; }
.task { margin: 8px 0; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }
.task-head { display: flex; justify-content: space-between; gap: 12px; }
.task pre { white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.4 inherit; }
footer { padding-top: 17px; color: var(--muted); font-size: 12px; text-align: center; }

.login { min-height: 100vh; display: grid; place-items: center; }
.login-box { width: min(420px, calc(100% - 32px)); padding: 28px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.login-box h1 { margin-top: 8px; font-size: 27px; }
.full { width: 100%; margin-top: 7px; }
[hidden] { display: none !important; }

.quota-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.quota-head .actions { justify-content: flex-end; }
.quota-switch { min-height: 38px; margin: 0; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.kpi-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 11px 0 13px; }
.kpi { min-width: 0; padding: 11px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); }
.kpi span, .kpi small { display: block; color: var(--muted); font-size: 12px; }
.kpi strong { display: block; margin: 4px 0; color: var(--text); font-size: 25px; line-height: 1.2; }
.kpi-duration strong { font-size: 22px; }
.quota-table { min-width: 720px; }
.quota-table td, .quota-table th { white-space: nowrap; }
.quota-table td:first-child, .quota-table th:first-child { width: auto; min-width: 190px; white-space: normal; }
.quota-table td:last-child { min-width: 150px; white-space: normal; }
.compact { padding: 18px 10px; }
.account-quota { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: 6px; padding-top: 5px; border-top: 1px solid var(--border); }
.account-quota small { flex-basis: 100%; margin-top: 0; }
.quota-badge { display: inline-flex; align-items: center; width: max-content; max-width: 100%; padding: 1px 7px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg); color: var(--muted); font-size: 12px; font-weight: 700; }
.quota-badge.good, .quota-badge.recovered { border-color: #b8dbcd; background: #e7f4ee; color: #126451; }
.quota-badge.critical, .quota-badge.removed-401 { border-color: #e4a4ac; background: #fff0f1; color: var(--danger); }
.quota-badge.protected, .quota-badge.disabled { border-color: #c5cee8; background: #eef1fb; color: #40558d; }
.quota-badge.warning { border-color: #e9d09a; background: #fff7e8; color: var(--warning); }
.quota-badge.checking { border-color: #badce4; background: #eaf5f8; color: #27697c; }
.quota-badge.invalid-checking, .quota-badge.unauthorized-checking { border-color: #e8c18f; background: #fff5e8; color: #8a4b13; }
.quota-badge.unauthorized { border-color: #e7b984; background: #fff0e5; color: #81430f; }
.upload-blocked { flex-basis: 100%; color: var(--danger); font-size: 12px; }

@media (min-width: 701px) {
  #accounts table { min-width: 900px; }
}

@media (max-width: 700px) {
  body { overflow-x: hidden; background: #f7f8fa; }
  header { min-height: 56px; padding: 8px 12px; }
  header > div { gap: 8px; }
  h1 { font-size: 19px; }
  header button { min-height: 40px; padding: 6px 10px; }
  main { max-width: 100%; padding: 12px 10px; }
  .intro { align-items: flex-start; flex-direction: column; gap: 3px; margin-bottom: 9px; }
  .intro h2 { font-size: 20px; }
  .intro p { margin-bottom: 2px; font-size: 13px; line-height: 19px; }

  nav { flex-wrap: nowrap; gap: 4px; margin: 0 -2px 10px; padding: 0 2px 7px; overflow-x: auto; scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  nav button { flex: 0 0 auto; min-height: 40px; padding: 6px 10px; font-size: 14px; }

  .panel { padding: 12px 10px; border-radius: 10px; }
  button { min-height: 42px; }
  .status-strip, .toolbar, .quota-head { align-items: stretch; flex-direction: column; gap: 7px; }
  .status-strip .actions, .toolbar .actions, .quota-head .actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 6px; }
  .status-strip .actions button, .toolbar .actions button, .quota-head .actions button, .quota-head .actions label { width: 100%; min-width: 0; }
  .hourly-refresh-strip { margin: 7px 0 4px; padding: 9px; }
  .hourly-refresh-strip .actions { grid-template-columns: 1fr; }
  .hourly-refresh-strip .actions button { white-space: normal; }
  .quota-head .actions { justify-content: stretch; }
  .quota-switch { min-height: 42px; }
  .search { width: 100%; max-width: none; margin: 4px 0; }
  .hint { padding: 7px 9px; font-size: 13px; line-height: 19px; }
  .form-grid { grid-template-columns: 1fr; }
  .task-head { flex-direction: column; }
  .pagination { justify-content: space-between; }

  #accounts .table-wrap { margin-top: 6px; overflow: visible; }
  #accounts table, #accounts tbody { display: block; width: 100%; }
  #accounts thead { display: none; }
  #account-rows { display: grid; gap: 8px; }
  #account-rows tr {
    position: relative;
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr) auto;
    gap: 5px 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
  }
  #account-rows td { display: block; width: auto; padding: 0; border: 0; }
  #account-rows td:nth-child(1) { grid-column: 1; grid-row: 1 / span 2; }
  #account-rows td:nth-child(2) { grid-column: 2; grid-row: 1; min-width: 0; }
  #account-rows td:nth-child(6) { grid-column: 3; grid-row: 1; }
  #account-rows td:nth-child(6) button { min-height: 34px; padding: 4px 9px; font-size: 13px; }
  #account-rows td:nth-child(3),
  #account-rows td:nth-child(4),
  #account-rows td:nth-child(5) { grid-column: 2 / 4; }
  #account-rows td:nth-child(3) { padding-top: 5px; border-top: 1px solid var(--border); }
  #account-rows td:nth-child(5) { color: var(--muted); font-size: 12px; }
  #account-rows td:nth-child(5)::before { content: "最近检测："; }
  #account-rows td small { max-width: none; }
  .account-quota { margin-top: 4px; }

  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin: 9px 0 11px; }
  .kpi { padding: 9px 10px; }
  .kpi strong { font-size: 22px; }
  .kpi-duration { grid-column: 1 / -1; }
  .quota-table-wrap { overflow: visible; }
  .quota-table, .quota-table tbody { display: block; min-width: 0; width: 100%; }
  .quota-table thead { display: none; }
  #quota-records { display: grid; gap: 8px; }
  #quota-records tr { display: block; padding: 9px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
  #quota-records td { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 8px; min-width: 0; padding: 3px 0; border: 0; white-space: normal; overflow-wrap: anywhere; }
  #quota-records td::before { color: var(--muted); font-size: 12px; }
  #quota-records td:nth-child(1)::before { content: "账号"; }
  #quota-records td:nth-child(2)::before { content: "变化"; }
  #quota-records td:nth-child(3)::before { content: "检测时间"; }
  #quota-records td:nth-child(4)::before { content: "耗尽用时"; }
  #quota-records td:nth-child(5)::before { content: "当前状态"; }
  .empty { padding: 24px 12px; }
  footer { padding-top: 13px; }
}
