:root {
  --bg: #eef3f8;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #d9e2ec;
  --primary: #2f80ed;
  --primary-dark: #2568c2;
  --warning: #f2994a;
  --danger: #eb5757;
  --success: #27ae60;
  --sidebar: #f4f7fb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
}

.hidden {
  display: none !important;
}

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

.auth-card {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(31, 41, 55, 0.08);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.auth-brand strong {
  display: block;
}

.auth-brand span {
  color: var(--muted);
  font-size: 12px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.auth-tab {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  padding: 9px 10px;
  font-weight: 700;
  cursor: pointer;
}

.auth-tab.active {
  background: #dceafd;
  color: #1e58b2;
  border-color: #c5dcfb;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-message {
  margin: 12px 0 0;
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}

.auth-message.error {
  color: #b91c1c;
}

.auth-message.success {
  color: #178a48;
}

.app-shell {
  display: grid;
  grid-template-columns: 190px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px 14px;
  border-bottom: 1px solid var(--line);
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #2f80ed, #1c5ab2);
}

.brand-text strong {
  display: block;
}

.brand-text span {
  color: var(--muted);
  font-size: 12px;
}

.menu {
  margin-top: 16px;
  display: grid;
  gap: 6px;
}

.menu-item {
  color: #334155;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 600;
}

.menu-item:hover {
  background: #e8eff8;
}

.menu-item.active {
  background: #dceafd;
  color: #1e58b2;
}

.main {
  padding: 12px 14px 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

.topbar h1 {
  margin: 0;
  font-size: 26px;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-box span {
  color: #334155;
  font-size: 13px;
  font-weight: 600;
}

.stats {
  display: flex;
  gap: 10px;
}

.stat-card {
  min-width: 90px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
  display: block;
  margin-bottom: 2px;
}

.stat-card strong {
  font-size: 22px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-top: 10px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 17px;
}

.grid3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

label span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}

input,
textarea,
select,
button {
  font-family: inherit;
  font-size: 14px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--text);
  background: #fff;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #96bdf3;
  box-shadow: 0 0 0 2px rgba(47, 128, 237, 0.12);
}

.import-wrap {
  display: grid;
  gap: 10px;
}

.import-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.import-region-field {
  width: 320px;
  max-width: 100%;
}

.import-actions {
  display: flex;
  gap: 10px;
}

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

.check-group {
  display: grid;
  gap: 4px;
}

.check-group label {
  color: #334155;
  font-size: 13px;
}

.check-group input[type="checkbox"] {
  width: auto;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.inline-field {
  width: 300px;
}

.inline-field.compact {
  width: 120px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  align-items: center;
}

.filters input {
  flex: 1;
  min-width: 220px;
}

.filters textarea {
  flex: 1;
  min-width: 280px;
  resize: vertical;
}

.filters select {
  width: 160px;
}

.view-section {
  display: block;
}

#pageSize {
  width: 110px;
}

.pager-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

#pageInfo {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  background: #edf2f7;
  color: #334155;
  font-weight: 700;
  cursor: pointer;
}

.btn:hover {
  filter: brightness(0.96);
}

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

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

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

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

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

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  min-width: 1080px;
  table-layout: auto;
}

thead {
  background: #f8fbff;
}

th,
td {
  border-bottom: 1px solid #edf2f7;
  padding: 8px 8px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

td.cell-ip {
  min-width: 128px;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: break-all;
}

th {
  font-size: 12px;
  color: #64748b;
}

tr:hover td {
  background: #fafcff;
}

.w-check {
  width: 36px;
  text-align: center;
}

.mono {
  font-family: "Consolas", "Courier New", monospace;
}

th:nth-child(2),
td:nth-child(2) {
  width: 40px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 56px;
}

th:nth-child(4),
td:nth-child(4) {
  width: 120px;
}

th:nth-child(5),
td:nth-child(5),
th:nth-child(8),
td:nth-child(8),
th:nth-child(9),
td:nth-child(9) {
  width: 128px;
}

th:nth-child(6),
td:nth-child(6) {
  width: 120px;
}

th:nth-child(7),
td:nth-child(7) {
  width: 110px;
}

th:nth-child(10),
td:nth-child(10) {
  width: 95px;
}

th:nth-child(11),
td:nth-child(11),
th:nth-child(12),
td:nth-child(12),
th:nth-child(13),
td:nth-child(13) {
  width: 80px;
}

th:nth-child(14),
td:nth-child(14) {
  width: 116px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  background: #edf2f7;
  color: #334155;
}

.badge.success {
  background: #dff6e8;
  color: #178a48;
}

.badge.warning {
  background: #fff3df;
  color: #ba7a17;
}

.empty-row {
  text-align: center;
  color: var(--muted);
  padding: 28px 0;
}

#actionLog {
  margin: 0;
  min-height: 220px;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0f172a;
  color: #d6e3ff;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .top-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .user-box {
    width: 100%;
    justify-content: space-between;
  }

  .stats {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .grid3 {
    grid-template-columns: 1fr;
  }

  .inline-field,
  .inline-field.compact {
    width: 100%;
  }

  .import-region-field {
    width: 100%;
  }

  .filters select,
  #pageSize {
    width: 100%;
  }

  .pager-controls {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  table {
    min-width: 980px;
  }
}
