:root {
  color-scheme: dark;
  --bg: #0b1017;
  --bg-2: #0f1822;
  --panel: #141c26;
  --panel-2: #101821;
  --panel-3: #172231;
  --line: #263746;
  --line-strong: #3d5364;
  --text: #eef6f8;
  --muted: #95a8b5;
  --label: #1d2a36;
  --input: #0d141c;
  --accent: #29c6bd;
  --accent-2: #4c8dff;
  --accent-3: #ff626a;
  --ok: #32c66a;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.32);
  --radius: 8px;
  --gap: 12px;
}

body.light {
  color-scheme: light;
  --bg: #eef4f7;
  --bg-2: #f7fbfc;
  --panel: #ffffff;
  --panel-2: #f6f9fb;
  --panel-3: #eef5f8;
  --line: #d7e3e8;
  --line-strong: #adc2cc;
  --text: #17232b;
  --muted: #607681;
  --label: #eaf3f5;
  --input: #fbfdfe;
  --accent: #18a7a4;
  --accent-2: #2f80ed;
  --accent-3: #ee4f58;
  --shadow: 0 16px 48px rgba(25, 71, 88, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: auto;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
  background:
    linear-gradient(180deg, rgba(76, 141, 255, 0.12), transparent 280px),
    linear-gradient(90deg, rgba(41, 198, 189, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, rgba(41, 198, 189, 0.04) 1px, transparent 1px),
    linear-gradient(135deg, var(--bg), var(--bg-2));
  background-size: auto, 86px 86px, 86px 86px, auto;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  height: 32px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--text);
  background: var(--panel-2);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.14s ease, color 0.14s ease, background 0.14s ease;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button.primary {
  border-color: var(--accent-2);
  background: var(--accent-2);
  color: #fff;
  font-weight: 700;
}

button.outline-primary {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  font-weight: 700;
}

.theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 8;
  min-width: 76px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(10px);
}

.workbench {
  width: min(1520px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 24px 0 34px;
}

.group-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-bottom: var(--gap);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.14);
  padding: 0 12px;
  min-height: 48px;
  overflow-x: auto;
}

.group-nav button {
  position: relative;
  height: 46px;
  border: 0;
  border-radius: 0;
  color: var(--muted);
  background: transparent;
  padding: 0 18px;
}

.group-nav button:hover,
.group-nav button.active {
  color: var(--text);
}

.group-nav button.active {
  color: var(--accent-2);
  font-weight: 800;
}

.group-nav button.active::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 0;
  height: 3px;
  border-radius: 999px 999px 0 0;
  background: var(--accent-2);
}

.page-view {
  display: none;
}

.page-view.active {
  display: grid;
}

.app-nav {
  position: fixed;
  left: max(16px, calc((100vw - 1720px) / 2));
  top: 24px;
  bottom: 24px;
  z-index: 9;
  width: 190px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: var(--shadow);
  padding: 14px;
  backdrop-filter: blur(14px);
}

.nav-brand {
  padding-bottom: 13px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.nav-brand strong {
  display: block;
  color: var(--accent-2);
  font-size: 22px;
  line-height: 1.05;
}

.nav-brand span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.app-nav nav {
  display: grid;
  gap: 7px;
}

.app-nav button {
  width: 100%;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 12px;
  border-color: transparent;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.app-nav button:hover,
.app-nav button.active {
  border-color: color-mix(in srgb, var(--accent-2) 48%, var(--line));
  color: var(--text);
  background: color-mix(in srgb, var(--accent-2) 18%, var(--panel-2));
}

.app-nav button.active {
  color: #fff;
  font-weight: 800;
}

.nav-flyout {
  position: absolute;
  left: calc(100% + 10px);
  top: 58px;
  width: 260px;
  display: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 98%, transparent);
  box-shadow: var(--shadow);
  padding: 12px;
}

.nav-flyout.open {
  display: block;
}

.nav-flyout-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.nav-flyout-head strong {
  font-size: 14px;
}

.nav-flyout-head button {
  width: 28px;
  height: 28px;
  padding: 0;
  justify-content: center;
}

.nav-flyout-list {
  display: grid;
  gap: 8px;
  padding-top: 10px;
}

.nav-flyout-list button {
  height: 36px;
  border-color: var(--line);
  background: var(--panel-2);
  color: var(--text);
}

.topbar {
  display: grid;
  grid-template-columns: 230px minmax(380px, 1fr) auto;
  gap: var(--gap);
  align-items: center;
  position: sticky;
  top: 10px;
  z-index: 5;
  margin-bottom: var(--gap);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 93%, transparent);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  backdrop-filter: blur(14px);
}

.brand strong {
  display: block;
  font-size: 24px;
  line-height: 1.1;
}

.brand strong span {
  color: var(--accent-2);
}

.brand small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.control,
.batch-proxy {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr);
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--input);
}

.control span,
.batch-proxy span {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--label);
  font-size: 13px;
}

.control input,
.batch-proxy input,
.batch-proxy select {
  min-width: 0;
  width: 100%;
  height: 32px;
  border: 0;
  outline: none;
  padding: 0 10px;
  color: var(--text);
  background: transparent;
  font-family: Consolas, "Microsoft YaHei", monospace;
}

.batch-proxy select {
  appearance: none;
}

.control-login {
  grid-template-columns: 110px minmax(0, 1fr);
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(310px, 0.92fr) minmax(420px, 1.25fr) minmax(300px, 0.85fr);
  gap: var(--gap);
  align-items: stretch;
}

.module {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.16);
  padding: 13px;
}

.module-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.module-head h2,
.section-title h2,
.batch-title h2,
.modal h2 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.2;
  font-weight: 800;
}

.module-head h2::before,
.section-title h2::before,
.batch-title h2::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 2px;
  background: var(--accent);
  vertical-align: 1px;
}

.module-head span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.account-module {
  display: grid;
  align-content: start;
  gap: 9px;
}

.row-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.row-control.two {
  grid-template-columns: minmax(0, 1fr) auto;
}

.row-control.three {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding-top: 4px;
}

.action-grid button {
  min-width: 0;
}

.profile-module {
  min-height: 358px;
}

.status-pill {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 12px;
  border: 1px solid color-mix(in srgb, var(--accent-2) 48%, var(--line));
  border-radius: var(--radius);
  color: var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 12%, var(--panel-2));
  font-weight: 800;
}

.profile-table {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  margin: 0;
}

.profile-table dt,
.profile-table dd {
  min-height: 32px;
  margin: 0;
  display: flex;
  align-items: center;
  border-bottom: 1px dashed var(--line);
  color: var(--muted);
  font-size: 13px;
}

.profile-table dd {
  min-width: 0;
  justify-content: flex-end;
  color: var(--text);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-stack {
  display: grid;
  grid-template-rows: minmax(300px, 1fr) minmax(126px, auto);
  gap: var(--gap);
  min-width: 0;
}

.photo-frame {
  position: relative;
  width: 100%;
  height: 300px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(41, 198, 189, 0.12), transparent 42%),
    linear-gradient(45deg, rgba(76, 141, 255, 0.12), transparent 44%),
    #08131a;
}

.photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-nav {
  position: absolute;
  top: 50%;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(238, 246, 248, 0.78);
  color: #22313d;
  font-size: 28px;
  line-height: 32px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
}

.photo-prev {
  left: 10px;
}

.photo-next {
  right: 10px;
}

.photo-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  display: flex;
  justify-content: center;
  gap: 7px;
}

.photo-dots span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.42);
}

.photo-dots span.active {
  width: 18px;
  background: #fff;
}

.log-row {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr);
  gap: 10px;
  min-height: 70px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
}

.log-row strong {
  min-width: 0;
  color: var(--text);
  line-height: 1.5;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.sex-panel {
  margin-top: var(--gap);
}

.sex-panel.page-view.active,
.media-work.page-view.active,
.system-work.page-view.active {
  display: block;
}

.section-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.section-title > div {
  flex: 1 1 260px;
}

.section-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.tabs {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 11px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
}

.tabs button {
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.tabs button.active {
  color: #fff;
  background: var(--accent-2);
}

.chips {
  min-height: 82px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
  padding-top: 12px;
}

.chip.selected {
  border-color: var(--accent);
  color: #061014;
  background: var(--accent);
  font-weight: 800;
}

.batch-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--gap);
  margin-top: var(--gap);
}

.batch-work {
  display: grid;
  grid-template-columns: minmax(430px, 0.42fr) minmax(560px, 0.58fr);
  gap: var(--gap);
}

.phone-rebind-work {
  grid-template-columns: minmax(520px, 0.42fr) minmax(720px, 0.58fr);
}

.batch-input-card,
.batch-result-card {
  min-width: 0;
}

.batch-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.batch-title h2.danger-title {
  color: var(--accent-3);
  font-size: 17px;
}

.batch-proxy {
  grid-template-columns: 88px minmax(0, 1fr);
  margin-bottom: 9px;
}

.rebind-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(170px, 1fr));
  gap: 8px;
}

.batch-input-card textarea {
  width: 100%;
  height: 310px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  padding: 10px;
  color: var(--text);
  background: var(--input);
  line-height: 1.55;
  font-family: Consolas, "Microsoft YaHei", monospace;
}

.batch-progress {
  position: relative;
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-2) 14%, var(--panel-2));
  margin-bottom: 10px;
}

.batch-progress div {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--ok);
  transition: width 0.18s ease;
}

.batch-progress span {
  position: absolute;
  inset: 0 9px 0 auto;
  display: flex;
  align-items: center;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.batch-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  border-bottom: 1px solid var(--line);
}

.batch-tabs button {
  height: 38px;
  border-color: transparent;
  border-radius: 7px 7px 0 0;
  color: var(--accent-2);
  background: var(--panel-2);
}

.batch-tabs button.active {
  color: #fff;
  background: var(--accent-2);
}

#batchResultList,
#bulkResultList,
#phoneRebindResultList {
  height: 316px;
  margin: 0;
  padding: 10px 12px;
  overflow: auto;
  color: var(--text);
  background: var(--panel-2);
  white-space: pre-wrap;
  word-break: break-all;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 12px;
  line-height: 1.55;
}

.phone-rebind-work .batch-input-card textarea {
  height: 360px;
}

.phone-rebind-work #phoneRebindResultList {
  height: 366px;
}

.phone-rebind-log {
  margin-top: var(--gap);
}

#phoneRebindLogList {
  height: 170px;
  margin: 0;
  padding: 11px 12px;
  overflow: auto;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-break: break-all;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 12px;
  line-height: 1.55;
}

.batch-actions,
.bulk-buttons {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 10px;
}

.bulk-buttons {
  justify-content: flex-end;
}

.media-actions,
.system-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: var(--gap);
}

.media-preview-row {
  width: min(360px, 100%);
}

.system-log-row {
  min-height: 96px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4, 9, 14, 0.58);
  backdrop-filter: blur(8px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(720px, 100%);
  max-height: min(720px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.modal.small {
  width: min(460px, 100%);
}

.tabs.compact {
  margin-top: 0;
}

.modal-chips {
  min-height: 110px;
}

.modal-field {
  margin-top: 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

@media (max-width: 1280px) {
  .workbench {
    width: min(1100px, calc(100vw - 28px));
    margin: 0 auto;
  }

  .topbar,
  .main-grid,
  .batch-grid,
  .batch-work {
    grid-template-columns: 1fr;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .side-stack {
    grid-template-columns: minmax(260px, 0.8fr) minmax(320px, 1fr);
    grid-template-rows: auto;
  }
}

@media (max-width: 720px) {
  .workbench {
    width: calc(100vw - 18px);
  }

  .theme-toggle {
    top: 14px;
    right: 14px;
  }

  .topbar,
  .module {
    border-radius: 10px;
    padding: 11px;
  }

  .brand strong {
    font-size: 22px;
  }

  .row-control,
  .row-control.two,
  .row-control.three,
  .control,
  .batch-proxy,
  .rebind-options,
  .side-stack {
    grid-template-columns: 1fr;
  }

  .control span,
  .batch-proxy span {
    justify-content: start;
    padding-left: 10px;
  }

  .top-actions,
  .action-grid,
  .section-title,
  .batch-actions,
  .bulk-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  button {
    width: 100%;
    padding: 0 8px;
  }

  .group-nav button {
    width: auto;
    min-width: 86px;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .photo-frame {
    height: 240px;
  }

  .log-row {
    grid-template-columns: 1fr;
  }
}

/* Page grouping must override module layout display rules below/above. */
.page-view:not(.active) {
  display: none !important;
}
