:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #1769e0;
  --primary-dark: #1154b4;
  --danger: #c62828;
  --ok-bg: #e8f5e9;
  --ok: #1b7f3a;
  --off-bg: #f3f4f6;
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--primary);
  text-decoration: none;
}

.shell {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  width: 224px;
  background: #101820;
  color: #fff;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand strong,
.brand span {
  display: block;
}

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

.brand span {
  color: #9ca3af;
  margin-top: 6px;
}

nav {
  display: grid;
  gap: 8px;
}

nav a {
  color: #d1d5db;
  padding: 10px 12px;
  border-radius: 6px;
}

nav a.active,
nav a:hover {
  background: #1f2937;
  color: #fff;
}

.main {
  flex: 1;
  padding: 28px;
  min-width: 0;
}

.login-main {
  width: 100%;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

.login-card {
  width: min(420px, 100%);
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: 24px;
  margin-bottom: 6px;
}

h2 {
  font-size: 17px;
  margin-bottom: 16px;
}

h3 {
  font-size: 14px;
  margin-bottom: 12px;
}

p,
.muted {
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 14px;
}

.grid-form {
  display: grid;
  grid-template-columns: 140px minmax(220px, 1fr) minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: #374151;
  font-weight: 600;
}

input,
select {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 10px 11px;
  font: inherit;
  background: #fff;
}

button,
.button,
.button-like {
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  font: inherit;
  white-space: nowrap;
}

button:hover,
.button:hover {
  background: var(--primary-dark);
  color: #fff;
}

.ghost {
  background: #fff;
  border: 1px solid var(--line);
  color: #374151;
}

.sidebar .ghost {
  background: transparent;
  color: #d1d5db;
  border-color: #374151;
}

.danger {
  background: #fff;
  border: 1px solid #ffcdd2;
  color: var(--danger);
}

.full {
  width: 100%;
}

.panel {
  margin-bottom: 18px;
  overflow-x: auto;
}

.narrow {
  max-width: 760px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #4b5563;
  font-size: 13px;
}

.center {
  text-align: center;
}

.truncate {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions,
.copy-line,
.metrics {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.copy-line {
  min-width: 280px;
}

.copy-line input {
  min-width: 220px;
}

.metrics {
  min-width: 140px;
}

.metrics span {
  color: var(--muted);
}

.metrics strong {
  color: var(--text);
}

.status {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}

.status.on {
  color: var(--ok);
  background: var(--ok-bg);
}

.status.off {
  color: #6b7280;
  background: var(--off-bg);
}

.flash {
  padding: 12px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
}

.flash.success {
  color: var(--ok);
  background: var(--ok-bg);
}

.flash.error {
  color: var(--danger);
  background: #ffebee;
}

.empty {
  text-align: center;
  padding: 54px 20px;
}

.empty.small {
  padding: 24px;
}

.generated {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  margin-bottom: 18px;
}

.generated > span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-cards.wide {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.stat-cards div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.stat-cards span {
  color: var(--muted);
  display: block;
  margin-bottom: 8px;
}

.stat-cards strong {
  font-size: 28px;
}

.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(100px, 190px) 1fr 48px;
  gap: 10px;
  align-items: center;
}

.bar-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #374151;
}

.bar-row div {
  height: 10px;
  background: #eef2f7;
  border-radius: 999px;
  overflow: hidden;
}

.bar-row i {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
}

.bar-row strong {
  text-align: right;
}

.bar-row em {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-style: normal;
  margin-top: 2px;
}

.bars.compact {
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.bars.compact .bar-row {
  grid-template-columns: minmax(128px, 180px) 1fr 42px;
}

.spaced {
  margin-top: 24px;
}

@media (max-width: 900px) {
  .shell {
    display: block;
  }

  .sidebar {
    width: 100%;
  }

  .grid-form,
  .split,
  .stat-cards {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 560px) {
  .stat-cards.wide {
    grid-template-columns: 1fr;
  }

  .bar-row,
  .bars.compact .bar-row {
    grid-template-columns: 1fr 1fr 40px;
  }
}
