:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --line: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --orange: #ea580c;
  --blue: #2563eb;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

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

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

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 48px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: var(--orange);
  color: #fff;
  font-weight: 800;
  border-radius: 8px;
}

.brand-title {
  font-weight: 700;
  line-height: 1.2;
}

.brand-subtitle {
  color: #9ca3af;
  font-size: 12px;
  margin-top: 4px;
}

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

.nav button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  color: #d1d5db;
  background: transparent;
  text-align: left;
  padding: 0 12px;
  cursor: pointer;
}

.nav button.active,
.nav button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.nav .logout-button {
  margin-top: 14px;
  color: #fca5a5;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 86px;
  padding: 22px 28px 14px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  position: sticky;
  top: 0;
  z-index: 5;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

.page-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}

.content {
  padding: 24px 28px 34px;
  display: grid;
  gap: 18px;
}

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

.compact-grid {
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  margin-bottom: 14px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
  min-height: 116px;
}

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

.metric-value {
  margin-top: 10px;
  font-size: 26px;
  line-height: 1.1;
  font-weight: 800;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.alert-panel {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-left: 5px solid var(--orange);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.alert-detail {
  margin-top: 6px;
  color: #7c2d12;
  font-size: 13px;
}

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

.panel-header {
  min-height: 54px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.panel-title {
  margin: 0;
  font-size: 16px;
}

.panel-body {
  padding: 16px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
}

.table-wrap {
  overflow: auto;
}

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

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

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  background: var(--panel-soft);
}

td {
  font-size: 13px;
}

.product-cell {
  max-width: 460px;
  min-width: 320px;
  white-space: normal;
  line-height: 1.45;
}

.subline {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.text-link {
  color: var(--blue);
  font-weight: 600;
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 600;
}

.badge.ok {
  color: #166534;
  background: #dcfce7;
}

.badge.warn {
  color: #92400e;
  background: #fef3c7;
}

.badge.bad {
  color: #991b1b;
  background: #fee2e2;
}

.badge.info {
  color: #1d4ed8;
  background: #dbeafe;
}

.filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

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

.field label {
  color: var(--muted);
  font-size: 12px;
}

.field input,
.field select {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 10px;
}

.login-panel {
  min-height: calc(100vh - 180px);
  display: grid;
  place-items: center;
}

.login-form {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
  box-shadow: var(--shadow);
}

.login-form h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.user-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.shortvideo-filters {
  grid-template-columns: minmax(160px, 220px) minmax(160px, 220px) auto auto;
}

.shortvideo-rule-form {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(220px, 1fr) minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.permission-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 360px;
  white-space: normal;
}

.permission-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 9px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
}

.permission-chip input {
  width: 15px;
  height: 15px;
}

.table-input {
  height: 34px;
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 9px;
}

.danger-button {
  color: var(--red);
  margin-left: 6px;
}

.primary-button {
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  padding: 0 15px;
  cursor: pointer;
}

.secondary-button {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.status-list {
  display: grid;
  gap: 10px;
}

.status-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.status-row:last-child {
  border-bottom: 0;
}

.progress {
  height: 8px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--blue);
}

.bar-list {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr) 90px;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}

.bar {
  height: 9px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--green);
}

.empty,
.error {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel-soft);
}

.error {
  color: var(--red);
  border-color: #fecaca;
  background: #fef2f2;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.toggle input {
  width: 18px;
  height: 18px;
}

.upload-box {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.upload-box input[type="file"] {
  flex: 1 1 320px;
  min-width: 260px;
}

.upload-box select {
  flex: 0 0 180px;
  height: 38px;
}

.upload-submit-button {
  min-width: 96px;
}

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

.sync-controls {
  grid-template-columns: minmax(160px, 220px) minmax(180px, 240px) minmax(160px, 220px) auto;
}

.runner-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

@media (max-width: 1100px) {
  #app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

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

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

  .split,
  .filters,
  .user-form,
  .shortvideo-rule-form,
  .shortvideo-filters {
    grid-template-columns: 1fr;
  }

  .permission-cell {
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .content,
  .topbar,
  .sidebar {
    padding-left: 14px;
    padding-right: 14px;
  }

  .metric-grid,
  .server-grid {
    grid-template-columns: 1fr;
  }

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

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

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

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