:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --line: #d9dee5;
  --line-strong: #c5ccd5;
  --text: #171a1f;
  --muted: #68717d;
  --accent: #16734a;
  --accent-hover: #0f5f3c;
  --danger: #b42318;
  --warning: #a15c00;
  --shadow: 0 12px 32px rgba(27, 34, 44, .12);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; background: var(--bg); }
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-panel { width: min(380px, 100%); padding: 32px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; color: #fff; background: #20262e; border-radius: 6px; font-weight: 800; }
.brand-mark.small { width: 34px; height: 34px; font-size: 13px; }
h1 { margin: 18px 0 26px; font-size: 24px; }
h2 { margin: 0; font-size: 19px; }
p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
label { display: grid; gap: 7px; color: #4c5561; font-size: 13px; font-weight: 600; }
.login-panel label + label { margin-top: 16px; }
input, select { width: 100%; min-height: 40px; padding: 8px 10px; color: var(--text); background: #fff; border: 1px solid var(--line-strong); border-radius: 5px; outline: none; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22, 115, 74, .12); }
button { min-height: 38px; padding: 8px 14px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--text); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tab:focus-visible { outline: 0; box-shadow: inset 0 0 0 2px rgba(22, 115, 74, .38); }
button.primary { background: var(--accent); color: #fff; font-weight: 700; }
button.primary:hover { background: var(--accent-hover); }
button.quiet { background: #fff; border-color: var(--line-strong); }
button.quiet:hover { background: #f2f4f6; }
button.wide { width: 100%; margin-top: 24px; }
.form-error { min-height: 18px; color: var(--danger); }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; background: #20262e; color: #fff; }
.brand-row, .account-row { display: flex; align-items: center; gap: 12px; }
.brand-row strong { display: inline-block; font-size: 16px; }
.service-state { margin-left: 12px; color: #8de0b5; font-size: 12px; }
.account-row { font-size: 13px; }
.account-row .quiet { min-height: 32px; padding: 5px 10px; color: #fff; background: transparent; border-color: #58616d; }
.tabs { height: 50px; display: flex; align-items: stretch; gap: 4px; padding: 0 28px; background: var(--surface); border-bottom: 1px solid var(--line); }
.tab { min-width: 92px; border: 0; border-radius: 0; border-bottom: 3px solid transparent; color: var(--muted); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.workspace { width: min(1440px, 100%); margin: 0 auto; padding: 28px; }
.view { display: none; }
.view.active { display: block; }
.section-heading { min-height: 50px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-heading.compact { min-height: 38px; margin-top: 30px; margin-bottom: 10px; align-items: center; }
.text-command { padding: 4px 0; min-height: auto; color: var(--accent); font-weight: 700; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); border: 1px solid var(--line); background: var(--surface); }
.metric-grid article { min-height: 108px; padding: 22px; border-right: 1px solid var(--line); }
.metric-grid article:last-child { border-right: 0; }
.metric-grid span { display: block; color: var(--muted); font-size: 13px; }
.metric-grid strong { display: block; margin-top: 10px; font-size: 30px; }
.table-wrap { width: 100%; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); }
table { width: 100%; min-width: 880px; border-collapse: collapse; font-size: 13px; }
th, td { height: 48px; padding: 9px 13px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: #4c5561; background: #f7f8fa; font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfc; }
th.actions, td.actions { text-align: right; }
.status { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 700; }
.status.success, .status.enabled { color: #11663f; background: #e3f5ea; }
.status.rejected, .status.disabled { color: #7b3440; background: #fbeaec; }
.status.rate_limited { color: #865000; background: #fff1d6; }
.mono { font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; }
.card-value { min-width: 110px; max-width: 260px; white-space: normal; overflow-wrap: anywhere; word-break: break-all; }
.truncate { display: inline-block; max-width: 170px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.row-command { min-height: 30px; padding: 4px 8px; color: var(--accent); }
.row-command.danger { color: var(--danger); }
.empty-row { height: 96px; color: var(--muted); text-align: center; }
.filter-bar { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(180px, 1fr) 120px minmax(130px, .7fr) auto auto; gap: 12px; align-items: end; margin-bottom: 14px; padding: 14px; background: var(--surface); border: 1px solid var(--line); }
.filter-bar input, .filter-bar select { min-height: 38px; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 14px; }
.pager span { min-width: 70px; text-align: center; color: var(--muted); font-size: 13px; }
dialog { width: min(820px, calc(100% - 28px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(14, 18, 23, .54); }
#profile-form { padding: 22px; overflow-y: auto; }
#profile-form > header, #profile-form > footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#profile-form > header { margin-bottom: 20px; }
#profile-form > footer { justify-content: flex-end; margin-top: 20px; }
.icon-button { width: 36px; min-height: 36px; padding: 0; font-size: 25px; color: var(--muted); }
.form-grid, .offset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
fieldset { margin: 20px 0 0; padding: 16px; border: 1px solid var(--line); }
legend { padding: 0 6px; font-size: 13px; font-weight: 700; }
.toggle-row { display: flex; align-items: center; gap: 9px; margin-top: 16px; }
.toggle-row input { width: 18px; min-height: 18px; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: min(380px, calc(100% - 48px)); padding: 12px 16px; color: #fff; background: #20262e; border-radius: 6px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .18s, transform .18s; }
.toast.show { opacity: 1; transform: translateY(0); }
@media (max-width: 900px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-grid article:nth-child(2) { border-right: 0; }
  .metric-grid article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .form-grid, .offset-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .topbar { padding: 0 14px; }
  .service-state { display: none; }
  .tabs { padding: 0 8px; overflow-x: auto; }
  .tab { min-width: 84px; }
  .workspace { padding: 18px 12px; }
  .section-heading { align-items: center; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-grid article { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric-grid article:last-child { border-bottom: 0; }
  .filter-bar { grid-template-columns: 1fr; }
  .filter-bar button { width: 100%; }
}
