:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --card: #ffffff;
  --text: #17211d;
  --muted: #66736d;
  --border: #dde6e1;
  --primary: #128c7e;
  --primary-dark: #0c6f64;
  --auto: #2c7a4b;
  --auto-dark: #205f39;
  --danger: #c43b3b;
  --warning: #b7791f;
  --shadow: 0 10px 30px rgba(20, 50, 40, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; }
button, .button-link {
  border: 0;
  border-radius: 9px;
  padding: 9px 14px;
  cursor: pointer;
  transition: 0.16s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
button:disabled { opacity: 0.55; cursor: not-allowed; }
.primary { color: #fff; background: var(--primary); }
.primary:hover { background: var(--primary-dark); }
.secondary { color: #21453c; background: #e7f2ee; }
.secondary:hover { background: #d8ebe4; }
.auto-button { color: #fff; background: var(--auto); }
.auto-button:hover { background: var(--auto-dark); }
.danger { color: #fff; background: var(--danger); }
.danger.ghost { color: var(--danger); background: #fae9e9; }
.full { width: 100%; }
.hidden { display: none !important; }
.muted { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.page { width: min(1600px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 60px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.login-wrap { min-height: calc(100vh - 48px); display: grid; place-items: center; }
.login-card { width: min(420px, 100%); padding: 34px; }
.login-card h1 { margin: 12px 0 0; }
.login-card label { display: grid; gap: 7px; margin: 18px 0; font-size: 14px; font-weight: 600; }
.brand-mark { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: var(--primary); font-weight: 800; }
input, select, textarea {
  min-height: 42px;
  border: 1px solid #ccd9d3;
  border-radius: 9px;
  padding: 8px 11px;
  background: #fff;
  color: var(--text);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(18, 140, 126, 0.12); }
input[type="checkbox"] { min-height: auto; width: 18px; height: 18px; accent-color: var(--primary); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.topbar h1 { margin: 0; }
.top-actions, .button-row, .inline-form, .filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pill { padding: 7px 11px; border-radius: 999px; background: #fff; border: 1px solid var(--border); font-size: 13px; }
.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 13px; margin-bottom: 18px; }
.stats-grid.stats-six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: 13px; padding: 18px; }
.stat-card span { display: block; color: var(--muted); font-size: 14px; }
.stat-card strong { display: block; font-size: 29px; margin-top: 7px; }
.section-card { padding: 19px; margin-top: 18px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 15px; }
.section-head h2 { margin: 0; font-size: 20px; }
.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; min-width: 1080px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid #edf1ef; font-size: 13px; vertical-align: middle; }
th { background: #f7faf8; color: #52625b; font-weight: 700; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions button, .actions .button-link { padding: 6px 9px; font-size: 12px; }
.status { display: inline-flex; border-radius: 999px; padding: 4px 8px; background: #e9efec; color: #53625c; font-weight: 700; font-size: 12px; }
.status.ready, .status.completed { color: #08715f; background: #ddf5ed; }
.status.partial { color: #8a5b0b; background: #fff1cf; }
.status.qr, .status.authenticated, .status.starting, .status.running, .status.queued { color: #8a5b0b; background: #fff1cf; }
.status.error, .status.failed, .status.auth_failure, .status.disconnected { color: #ad2f2f; background: #fde4e4; }
.error-text { color: #a63a3a; max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filters { margin-bottom: 12px; }
.filters > input:not([type="date"]) { min-width: 250px; }
.export-filters { align-items: flex-end; }
.date-field { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.date-field input { min-width: 150px; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(13, 25, 20, 0.55); display: grid; place-items: center; padding: 18px; }
.modal-panel { width: min(760px, 100%); max-height: 88vh; overflow: hidden; background: #fff; border-radius: 14px; box-shadow: 0 25px 70px rgba(0, 0, 0, 0.24); }
.modal-panel-wide { width: min(980px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 18px; overflow: auto; max-height: calc(88vh - 65px); }
.icon-button { width: 34px; height: 34px; border-radius: 50%; padding: 0; font-size: 23px; background: #eef3f1; }
.qr-wrap { text-align: center; }
.qr-wrap img { width: min(360px, 100%); border: 1px solid var(--border); border-radius: 12px; }
.group-list { display: grid; gap: 9px; }
.group-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; }
.group-item.auto-enabled { border-color: #8bc9aa; background: #f4fbf7; }
.group-item strong { display: block; }
.group-select-wrap { display: flex; align-items: flex-start; gap: 11px; min-width: 0; flex: 1; cursor: pointer; }
.group-select-wrap > span { min-width: 0; }
.group-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px; background: #f5f9f7; border: 1px solid var(--border); border-radius: 10px; }
.sticky-toolbar { position: sticky; top: -18px; z-index: 3; box-shadow: 0 5px 15px rgba(20, 50, 40, 0.08); }
.check-label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.group-help { margin: 10px 2px 12px; }
.auto-badge { display: inline-flex; margin-top: 5px; padding: 3px 7px; border-radius: 999px; background: #ddf5e5; color: #24633c; font-size: 12px; font-weight: 700; }
.toast { position: fixed; top: 18px; right: 18px; z-index: 50; max-width: 460px; padding: 12px 15px; color: #fff; background: #243b34; border-radius: 10px; box-shadow: var(--shadow); }
.toast.error { background: #a53636; }
.empty { text-align: center; color: var(--muted); padding: 28px !important; }

@media (max-width: 1200px) {
  .stats-grid.stats-six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-grid.stats-six { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar, .section-head { align-items: flex-start; flex-direction: column; }
  .sticky-toolbar { position: static; }
}
@media (max-width: 560px) {
  .page { width: min(100% - 18px, 1600px); padding-top: 12px; }
  .stats-grid, .stats-grid.stats-six { grid-template-columns: 1fr 1fr; }
  .stat-card { padding: 14px; }
  .section-card { padding: 13px; }
  .inline-form input, .inline-form button { width: 100%; }
  .group-item { align-items: stretch; flex-direction: column; }
  .group-item > button { width: 100%; }
}

.batch-badge { display: inline-flex; margin-top: 4px; padding: 3px 7px; border-radius: 999px; background: #e7eef8; color: #34567b; font-size: 12px; font-weight: 700; }
.job-delete { padding: 6px 10px; font-size: 12px; }
.export-dialog { display: grid; gap: 16px; }
.export-dialog > label, .export-date-grid label { display: grid; gap: 7px; font-weight: 600; }
.export-date-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.export-account-fixed { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: #f7faf8; }
.export-account-fixed span { color: var(--muted); }
@media (max-width: 560px) { .export-date-grid { grid-template-columns: 1fr; } }


.account-head-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.join-groups-form { display: grid; gap: 14px; }
.join-groups-form > label { display: grid; gap: 7px; font-weight: 700; }
.join-links { width: 100%; min-height: 220px; resize: vertical; border: 1px solid #ccd9d3; border-radius: 9px; padding: 11px; background: #fff; color: var(--text); outline: none; }
.join-summary { margin-top: 14px; padding: 11px 12px; border-radius: 9px; background: #f1f7f4; font-weight: 700; }
.join-result-list { display: grid; gap: 7px; margin-top: 10px; }
.join-result { display: grid; grid-template-columns: 52px minmax(180px, 1fr) minmax(160px, 1fr); gap: 10px; align-items: center; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; }
.join-result span { font-weight: 800; }
.join-result.ok span { color: #08715f; }
.join-result.failed span { color: #ad2f2f; }
.join-result code, .join-result small { overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .account-head-actions { width: 100%; justify-content: flex-start; }
  .join-result { grid-template-columns: 1fr; }
}

.status.stopped { color: #53625c; background: #e9efec; }


.change-filter-bar { display: flex; align-items: flex-end; gap: 9px; flex-wrap: wrap; margin-bottom: 12px; }
.change-filter-bar > input { min-width: 220px; }
.change-backfill { margin: 10px 0 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: #f7faf8; }
.change-backfill.active { border-color: #e1bf70; background: #fff7df; color: #79520b; font-weight: 700; }
.change-table { min-width: 1050px; }
.change-type { display: inline-flex; border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 800; }
.change-join, .change-promote { color: #08715f; background: #ddf5ed; }
.change-leave, .change-removed, .change-demote { color: #ad2f2f; background: #fde4e4; }
@media (max-width: 760px) {
  .change-filter-bar > * { width: 100%; }
  .change-filter-bar .date-field input { width: 100%; }
}
