:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #eef4f2;
  --line: #d9e1e8;
  --text: #18212f;
  --muted: #687487;
  --accent: #0f766e;
  --accent-dark: #0b5f58;
  --danger: #b42318;
  --warning: #b25e09;
  --ok: #137333;
  --nav: #142033;
  --nav-active: #e8f5f2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Microsoft YaHei", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

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

button {
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  min-height: 34px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  border-color: #cfd8e3;
  background: #eef2f6;
  color: #98a2b3;
  cursor: not-allowed;
}

button.secondary {
  background: #fff;
  color: var(--accent);
}

button.secondary:disabled {
  color: #98a2b3;
  background: #f8fafc;
}

button.danger {
  border-color: var(--danger);
  background: var(--danger);
}

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

textarea {
  min-height: 74px;
  resize: vertical;
}

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

.app-hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef3f8;
}

.login-panel {
  width: min(100%, 420px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(20, 32, 51, 0.12);
  padding: 24px;
}

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

.login-brand h1 {
  margin: 0;
  font-size: 22px;
}

.login-brand p {
  margin: 4px 0 0;
  color: var(--muted);
}

.login-field {
  margin-bottom: 14px;
}

.login-status {
  min-height: 20px;
  margin: 0 0 12px;
  color: var(--danger);
  font-size: 13px;
}

.login-panel button {
  width: 100%;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
}

.sidebar {
  background: var(--nav);
  color: #fff;
  padding: 18px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 18px;
  padding: 4px 4px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #16a394;
  font-size: 20px;
  font-weight: 700;
}

.brand h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.brand p {
  margin: 3px 0 0;
  color: #b8c3d4;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  border: 0;
  background: transparent;
  color: #dbe4f0;
  text-align: left;
  border-radius: 6px;
}

.nav button.active {
  background: var(--nav-active);
  color: var(--nav);
}

.main {
  min-width: 0;
}

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

.topbar h2 {
  margin: 0;
  font-size: 22px;
}

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

.server-box {
  display: grid;
  grid-template-columns: minmax(220px, 320px) auto auto auto;
  gap: 8px;
  align-items: end;
}

.server-box label {
  margin: 0;
}

.server-box label[for="baseUrl"] {
  grid-column: 1;
}

.server-box input {
  min-width: 0;
}

.form-band {
  padding: 18px 24px 0;
}

.form-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

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

.field-wide {
  grid-column: span 2;
}

.field-full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

.table-band {
  padding: 18px 24px 24px;
}

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

.toolbar-left {
  display: flex;
  gap: 8px;
  align-items: center;
}

.toolbar input {
  width: 260px;
}

.table-wrap {
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.compact-table table {
  min-width: 0;
  table-layout: fixed;
}

.compact-table th,
.compact-table td {
  padding: 8px 9px;
  white-space: normal;
}

.compact-table .cell-wrap {
  max-width: none;
  max-height: 46px;
  overflow: hidden;
  word-break: break-all;
}

.dashboard-wrap {
  overflow: visible;
  background: transparent;
  border: 0;
}

.dashboard-wrap > table {
  min-width: 0;
}

.dashboard-wrap > table > tbody > tr > td.dashboard-cell {
  padding: 0;
  border: 0;
  white-space: normal;
}

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

.metric-card,
.dashboard-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-card {
  min-height: 118px;
  padding: 15px;
}

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

.metric-value {
  margin-top: 10px;
  color: var(--text);
  font-size: 28px;
  font-weight: 700;
}

.metric-sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.metric-sub span {
  color: var(--accent);
  font-weight: 700;
  margin-right: 6px;
}

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

.dashboard-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dashboard-panel {
  padding: 14px;
  min-width: 0;
}

.dashboard-panel h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

.rank-row {
  display: grid;
  gap: 6px;
  padding: 8px 0;
  border-top: 1px solid #eef2f6;
}

.rank-row:first-of-type {
  border-top: 0;
}

.rank-main {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.rank-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-bar {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f6;
}

.rank-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.rank-meta,
.empty-panel {
  color: var(--muted);
  font-size: 12px;
}

.mini-table {
  min-width: 0;
  table-layout: fixed;
}

.mini-table td {
  padding: 8px 6px;
  border-bottom: 1px solid #eef2f6;
  white-space: normal;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 11px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  background: #f8fafc;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

td {
  color: #263241;
}

td .mono {
  font-family: Consolas, monospace;
}

.cell-wrap {
  max-width: 280px;
  white-space: normal;
  word-break: break-all;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef2f6;
  color: #344054;
  font-size: 12px;
}

.status.active,
.status.OK,
.status.DEDUCTED,
.status.SUCCESS {
  background: #e8f5ed;
  color: var(--ok);
}

.status.disabled,
.status.frozen,
.status.DOWN,
.status.FAILED,
.status.REFUNDED,
.status.TIMEOUT {
  background: #fff1f0;
  color: var(--danger);
}

.status.WARN,
.status.PROCESSING,
.status.POINTS_FROZEN,
.status.pending {
  background: #fff7e6;
  color: var(--warning);
}

.status.SKIPPED {
  background: #eef2f6;
  color: #475467;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.row-actions button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.pagination-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.pagination-controls button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.page-jump,
.page-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--muted);
}

.page-jump input {
  width: 72px;
  min-height: 30px;
}

.page-size select {
  width: 82px;
  min-height: 30px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 460px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #172033;
  color: #fff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

  .sidebar {
    position: static;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .server-box,
  .form-grid,
  .metric-grid,
  .dashboard-grid,
  .dashboard-grid.two {
    grid-template-columns: 1fr;
  }

  .field-wide,
  .field-full {
    grid-column: auto;
  }

  .pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .pagination-controls {
    justify-content: flex-start;
  }
}
