:root {
  --bg: #eef3fb;
  --card: #ffffff;
  --line: #d8e1ee;
  --text: #1f2a3d;
  --muted: #63708a;
  --primary: #2b6de2;
  --primary-hover: #2157b7;
  --danger: #cb3f3f;
  --danger-hover: #a72f2f;
  --success-bg: #e9f9ef;
  --success-text: #1f7a42;
  --error-bg: #fdeeee;
  --error-text: #9a3030;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top right, #dbe9ff, var(--bg) 45%);
}

.auth-body,
.panel-body {
  min-height: 100vh;
}

.auth-container {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(96vw, 560px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 14px 36px rgba(36, 64, 121, 0.12);
}

.auth-header h1,
.topbar h1,
.panel-card h2 {
  margin: 0 0 6px;
}

.auth-header p,
.topbar p {
  margin: 0;
  color: var(--muted);
}

.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0;
}

.tab-btn {
  border: 1px solid var(--line);
  background: #f7faff;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.admin-entry {
  margin-left: auto;
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.form-grid {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid #c6d3e7;
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}

input:focus,
select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(43, 109, 226, 0.16);
}

.inline-group {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.captcha-image {
  width: 120px;
  height: 40px;
  border: 1px solid #c6d3e7;
  border-radius: 8px;
  cursor: pointer;
}

.btn-primary,
.btn-secondary,
.btn-small {
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #edf3ff;
  color: var(--primary);
  border: 1px solid #c3d4f8;
}

.btn-secondary:hover {
  background: #dce8ff;
}

.btn-secondary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-small {
  background: #f4f8ff;
  border: 1px solid #bfd2f4;
  color: #244d93;
  padding: 8px 10px;
  font-size: 12px;
}

.btn-danger {
  background: #ffefef;
  border-color: #f0b9b9;
  color: var(--danger);
}

.btn-danger:hover {
  background: #ffdede;
  color: var(--danger-hover);
}

.alert {
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 14px;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.alert-error {
  background: var(--error-bg);
  color: var(--error-text);
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 16px 24px;
}

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

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--primary);
  border: 1px solid #bed1f7;
  border-radius: 8px;
  padding: 8px 12px;
  background: #f7fbff;
}

.auth-action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-container {
  max-width: 1160px;
  margin: 20px auto;
  padding: 0 16px 16px;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
}

.panel-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

.highlight {
  font-size: 17px;
}

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.stat-card {
  display: grid;
  gap: 10px;
}

.stat-number {
  font-size: 38px;
  font-weight: 700;
  color: #1f4ca9;
  margin: 0;
}

.table-wrapper {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid #e3ebf6;
  text-align: left;
  padding: 10px 8px;
  vertical-align: top;
  font-size: 13px;
}

.admin-table th {
  color: #33425f;
  background: #f8fbff;
}

.user-select-cell {
  width: 64px;
  text-align: center !important;
  vertical-align: middle !important;
}

.user-select-checkbox {
  appearance: auto;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  border: none;
  box-shadow: none;
  vertical-align: middle;
  cursor: pointer;
}

.mini-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.mini-form input:disabled,
.mini-form button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.action-hint {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

.proxy-header h2 {
  margin-bottom: 0;
}

.proxy-table {
  min-width: 860px;
}

.proxy-actions-cell {
  display: grid;
  gap: 8px;
}

.whitelist-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.whitelist-item-form {
  display: inline-flex;
  align-items: center;
  border: 1px solid #bfd2f4;
  border-radius: 999px;
  background: #f4f8ff;
  overflow: hidden;
}

.whitelist-tag {
  padding: 4px 10px;
  font-size: 12px;
  color: #1f4ca9;
}

.tag-delete-btn {
  border: none;
  border-left: 1px solid #bfd2f4;
  background: transparent;
  color: #6c7892;
  width: 24px;
  height: 24px;
  cursor: pointer;
}

.tag-delete-btn:hover {
  color: #a72f2f;
  background: #ffe8e8;
}

.muted-text {
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  margin: 0;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(21, 29, 43, 0.42);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 18px;
}

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

.modal-card {
  width: min(94vw, 520px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 16px 42px rgba(17, 36, 82, 0.22);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.modal-header h3 {
  margin: 0;
}

.modal-close {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  color: #607190;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

body.modal-open {
  overflow: hidden;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 640px) {
  .auth-card {
    padding: 16px;
  }

  .inline-group {
    grid-template-columns: 1fr;
  }

  .captcha-image {
    width: 100%;
    max-width: 140px;
  }
}
