:root {
  color-scheme: light;
  font: 14px/1.5 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  background: #f5f7fa;
  color: #182836;
  --muted: #556676;
  --border: #dfe6ec;
  --teal: #0d6359;
}

* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button:not(:disabled), select, summary, input[type="checkbox"]:not(:disabled) { cursor: pointer; }
:focus-visible { outline: 2px solid #0c796b; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 17px; line-height: 1.35; }
h3 { font-size: 14px; }

.wrap { width: min(1160px, calc(100% - 48px)); margin-inline: auto; }
.masthead { border-bottom: 1px solid var(--border); background: #fff; }
.masthead-inner, .brand, .local { display: flex; align-items: center; gap: 10px; }
.masthead-inner { justify-content: space-between; min-height: 59px; }
.brand { font-size: 16px; font-weight: 700; }
.brand-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; color: white; background: var(--teal); }
.brand-icon svg { width: 20px; height: 20px; }
.local { gap: 7px; font-size: 12px; color: var(--muted); }
.local i, .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #218d76; }
.amber { background: #c27a20; }

main.wrap { padding-block: 30px 42px; }
.intro { margin-bottom: 19px; }
h1 { font-size: clamp(25px, 4vw, 33px); line-height: 1.2; font-weight: 700; }
.intro p { margin-top: 6px; color: var(--muted); }
.stats, .card { background: #fff; border: 1px solid var(--border); border-radius: 12px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0 0 20px; }
.stats > div { padding: 12px 18px; }
.stats > div + div { border-inline-start: 1px solid var(--border); }
.stats dt { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.stats dd { margin: 1px 0 0; font-size: 23px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.workspace { display: grid; grid-template-columns: 232px minmax(0, 1fr); align-items: start; gap: 18px; }
.panel-heading { padding: 16px 18px; }
.panel-heading p { margin-top: 4px; color: var(--muted); font-size: 13px; }
.import-step { padding: 13px 18px; border-top: 1px solid var(--border); }
.import-step h3 { margin-bottom: 9px; }
.upload button { width: 100%; }
.import-help { padding: 11px 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.import-help summary { width: fit-content; color: var(--teal); font-weight: 600; }
.import-help p { margin-top: 8px; }
.import-help code { display: block; margin-top: 4px; padding: 6px 8px; border-radius: 5px; background: #f3f6f8; color: #32465a; overflow-wrap: anywhere; }

.button, input[type="search"], select, input[type="number"] { min-height: 36px; border-radius: 7px; font-size: 13px; }
.button { padding: 6px 11px; border: 1px solid transparent; font-weight: 650; white-space: nowrap; }
.button:disabled { background: #f1f4f6; border-color: #e3e9ee; color: #647485; cursor: not-allowed; }
.secondary { border-color: #cbd7df; color: #24394a; background: #fff; }
.secondary:not(:disabled):hover { background: #f0f5f7; border-color: #a4b7c3; }
.primary { background: var(--teal); color: #fff; }
.primary:not(:disabled):hover { background: #094e46; }
.danger { background: #a33530; color: #fff; }
.danger:not(:disabled):hover { background: #862a26; }
.quiet { color: var(--teal); background: transparent; }
.quiet:hover { background: #eaf6f2; }

.inventory-heading, .inventory-label, .controls, .filters, .pagination, .actions, .dialog-actions { display: flex; align-items: center; gap: 8px; }
.inventory-heading, .controls, .pagination { justify-content: space-between; flex-wrap: wrap; }
.inventory-label { flex-wrap: wrap; }
.count { padding: 2px 8px; border-radius: 99px; background: #edf2f6; color: var(--muted); font-size: 12px; }
.views { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 18px 12px; }
.views .button { color: var(--muted); background: transparent; }
.views .button:hover { background: #f0f5f7; }
.views .button[aria-pressed="true"] { color: var(--teal); background: #e7f4ef; }
.views .count { margin-left: 3px; }
.controls { padding: 0 18px 13px; }
.filters { flex: 1 1 auto; min-width: 0; }
.selection-actions { flex-wrap: wrap; }
.search { position: relative; flex: 0 1 240px; min-width: 0; }
.search svg { position: absolute; left: 8px; top: 9px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
input[type="search"], select, input[type="number"] { border: 1px solid #cbd7df; color: #24394a; background: #fff; padding: 6px 9px; }
input[type="search"] { width: 100%; padding-left: 30px; }
input[type="search"]::placeholder { color: var(--muted); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--teal); margin: 0; vertical-align: middle; }
.feedback { margin: 8px 0 0; padding: 7px 9px; border-radius: 7px; background: #eaf6f2; color: #195a50; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.feedback.error { color: #902f29; background: #fcefed; }
.inventory-feedback { margin: 0 18px 12px; }

.table-wrap { overflow-x: auto; border-radius: 0 0 12px 12px; }
table { border-collapse: collapse; width: 100%; table-layout: fixed; }
th, td { text-align: left; padding: 9px 10px; border-top: 1px solid var(--border); overflow-wrap: anywhere; font-size: 13px; }
th { background: #f6f8fa; color: #45596c; font-size: 12px; font-weight: 650; }
th:first-child { width: 44px; }
th:first-child, td:first-child { padding-left: 18px; }
th.proxy-column { width: 29%; }
.state-column { width: 88px; }
.action-column { width: 150px; }
td.proxy-column, .compact-proxy { color: var(--muted); }
.compact-proxy, .compact-email-label { display: none; }
.google-table .proxy-column, .google-table .compact-email-label { display: none; }
.google-table .desktop-email-label { display: inline; }
tbody tr:hover { background: #f9fbfc; }
.badge { display: inline-block; border-radius: 99px; padding: 3px 7px; font-size: 12px; white-space: nowrap; }
.badge + .badge { margin-inline-start: 4px; }
.ready { color: #195a50; background: #e7f4ef; }
.waiting { color: #77480b; background: #fbf1dd; }
.neutral { color: #45596c; background: #edf2f6; }
.row-action { min-height: 30px; padding: 3px 5px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 2px; }
.remove-proxy { color: #a33530; }
.remove-proxy:hover { background: #fcefed; }
.empty { display: grid; min-height: 180px; align-content: center; justify-items: center; gap: 5px; padding: 20px; border-top: 1px solid var(--border); text-align: center; }
.empty span { color: var(--muted); font-size: 13px; }
.pagination { padding: 11px 18px; border-top: 1px solid var(--border); }
.page-size { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

dialog { width: min(385px, calc(100% - 28px)); max-height: calc(100% - 28px); padding: 21px; border: 1px solid var(--border); border-radius: 13px; color: inherit; box-shadow: 0 16px 56px #15253630; }
dialog::backdrop { background: #15253673; }
.dialog-description { margin-top: 6px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.field { display: grid; gap: 5px; margin-top: 14px; font-size: 13px; }
.field textarea { width: 100%; padding: 7px 9px; border: 1px solid #cbd7df; border-radius: 7px; color: #24394a; resize: vertical; }
.field input[type="password"] { width: 100%; min-height: 38px; padding: 7px 9px; border: 1px solid #cbd7df; border-radius: 7px; color: #24394a; background: #fff; }
.field input[type="password"]:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 3px #0d635918; }
.example { display: block; margin-top: 7px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.dialog-actions { justify-content: flex-end; margin-top: 18px; }

@media (max-width: 820px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .workflow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workflow .panel-heading, .import-help { grid-column: 1 / -1; }
  .import-step + .import-step { border-inline-start: 1px solid var(--border); }
  .import-step.google-import { grid-column: 1 / -1; border-inline-start: 0; }
}

@media (max-width: 540px) {
  .wrap { width: calc(100% - 28px); }
  main.wrap { padding-top: 22px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats > div { padding: 9px 13px; }
  .stats > div:nth-child(3) { border-inline-start: 0; }
  .stats > div:nth-child(n+3) { border-top: 1px solid var(--border); }
  .panel-heading, .import-step, .import-help, .controls, .pagination, .views { padding-inline: 12px; }
  .inventory-feedback { margin-inline: 12px; }
  .filters { flex-wrap: wrap; }
  .search { flex-basis: 100%; }
  th, td { padding-inline: 5px; }
  th:first-child, td:first-child { padding-left: 10px; }
  th:first-child { width: 32px; }
  .state-column { width: 72px; }
  .action-column { width: 76px; }
  .proxy-column, .desktop-email-label { display: none; }
  .compact-email-label { display: inline; }
  .compact-proxy { display: block; margin-top: 2px; font-size: 12px; }
}

/* ---------- 内部版：登录态 ---------- */

.account-bar { display: flex; align-items: center; gap: 8px; }
.account-bar .local { gap: 7px; }
.account-bar .button { min-height: 32px; padding: 4px 9px; }

body[data-role="member"] .workflow { display: none; }
body[data-role="member"] .workspace { grid-template-columns: minmax(0, 1fr); }
body[data-role="member"] #selection-actions,
body[data-role="member"] #selection-filter { display: none !important; }
body[data-role="member"] #download-backup { display: none; }
body[data-role="member"] #open-users { display: none; }

#users-dialog { width: min(760px, calc(100% - 28px)); }
.user-create { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.user-create .feedback, .user-create .dialog-actions { grid-column: 1 / -1; }
.users-wrap { max-height: 38vh; overflow: auto; margin-top: 14px; border: 1px solid var(--border); border-radius: 9px; }
.users-table { table-layout: auto; }
.users-table th, .users-table td { white-space: nowrap; }
.users-table .row-actions { gap: 4px; }

@media (max-width: 540px) {
  .user-create { grid-template-columns: minmax(0, 1fr); }
}

#records-dialog { width: min(620px, calc(100% - 28px)); }
.records-table { max-height: 46vh; overflow: auto; margin-top: 12px; border: 1px solid var(--border); border-radius: 9px; }
.records-table table { table-layout: auto; }
.records-table th, .records-table td { white-space: nowrap; }
.records-table th:first-child, .records-table td:first-child { padding-left: 12px; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #e7f4ef 0%, #f5f7fa 60%);
}
.login-card {
  width: min(380px, 100%);
  padding: 28px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 18px 60px #1525361a;
}
.login-brand { margin-bottom: 16px; }
.login-card h1 { font-size: 26px; }
.login-sub { margin-top: 6px; color: var(--muted); font-size: 13px; }
.login-card form { margin-top: 18px; display: grid; }
.login-card .field input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #cbd7df;
  border-radius: 8px;
  color: #24394a;
  background: #fff;
}
.login-card .field input:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 3px #0d635918; }
.login-submit { margin-top: 14px; width: 100%; min-height: 42px; font-size: 14px; }
.login-foot { margin-top: 16px; color: var(--muted); font-size: 12px; line-height: 1.6; }
