:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #dbe4ef;
  --text: #111827;
  --muted: #64748b;
  --blue: #2563eb;
  --cyan: #0891b2;
  --green: #059669;
  --amber: #d97706;
  --red: #dc2626;
  --violet: #7c3aed;
  --shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font-family: inherit;
}

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

.admin-sidebar {
  background: #102033;
  color: #e5eef8;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-brand {
  min-height: 86px;
  padding: 20px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.26);
}

.admin-brand-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
}

.admin-brand-subtitle {
  margin-top: 4px;
  font-size: 11px;
  color: #9fb0c7;
  line-height: 1.35;
}

.admin-nav {
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-nav-item {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #b9c7d9;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  font-size: 14px;
  text-align: left;
  transition: background 0.16s ease, color 0.16s ease;
}

.admin-nav-item i {
  width: 18px;
  text-align: center;
}

.admin-nav-item:hover,
.admin-nav-item.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.admin-nav-item.active {
  box-shadow: inset 3px 0 0 var(--cyan);
}

.admin-sidebar-foot {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-sidebar-foot a {
  color: #c6d3e4;
  text-decoration: none;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.admin-topbar {
  min-height: 86px;
  padding: 18px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.admin-topbar h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.25;
}

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

.admin-user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 999px;
  background: #eef6ff;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.admin-content {
  padding: 24px 28px 32px;
  overflow: auto;
}

.admin-loading,
.admin-empty,
.admin-error {
  min-height: 180px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
}

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

.overview-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.metric-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.metric-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.metric-value {
  margin-top: 12px;
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
}

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

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 16px;
}

.admin-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-title {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-grid {
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.status-row {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.status-row strong {
  display: block;
  font-size: 18px;
  margin-top: 4px;
}

.failure-list {
  padding: 8px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.failure-item {
  border: 1px solid #fee2e2;
  background: #fff7f7;
  border-radius: 8px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  font-size: 13px;
}

.failure-type {
  color: var(--red);
  font-weight: 700;
}

.failure-message {
  color: #7f1d1d;
  margin-top: 3px;
  line-height: 1.5;
}

.table-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-toolbar {
  padding: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.table-toolbar input,
.table-toolbar select {
  height: 36px;
  border-radius: 7px;
  border: 1px solid #cbd5e1;
  background: #fff;
  padding: 0 10px;
  color: #1f2937;
  font-size: 13px;
  outline: none;
}

.table-toolbar input:focus,
.table-toolbar select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.toolbar-btn {
  height: 36px;
  border: 0;
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  padding: 0 14px;
  font-weight: 600;
  cursor: pointer;
}

.table-title-line {
  padding: 16px 16px 4px;
}

.table-title-line h2 {
  margin: 0;
  font-size: 18px;
}

.table-title-line p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
}

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

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

.admin-table th {
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.admin-table tbody tr:hover {
  background: #f8fbff;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-completed,
.status-active,
.status-success {
  color: #065f46;
  background: #d1fae5;
}

.status-processing,
.status-downloading,
.status-validating,
.status-collecting {
  color: #1d4ed8;
  background: #dbeafe;
}

.status-pending,
.status-skipped {
  color: #475569;
  background: #e2e8f0;
}

.status-failed,
.status-suspended {
  color: #991b1b;
  background: #fee2e2;
}

.status-inactive {
  color: #92400e;
  background: #fef3c7;
}

.text-muted {
  color: var(--muted);
}

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

.pagination {
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

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

.pagination button {
  height: 32px;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 7px;
  padding: 0 11px;
  cursor: pointer;
}

.pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 1100px) {
  .admin-shell {
    grid-template-columns: 76px 1fr;
  }

  .admin-brand {
    justify-content: center;
    padding: 18px 10px;
  }

  .admin-brand > div:not(.admin-brand-icon),
  .admin-nav-item span,
  .admin-sidebar-foot {
    display: none;
  }

  .admin-nav-item {
    justify-content: center;
  }

  .overview-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

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

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

  .admin-sidebar {
    display: none;
  }

  .admin-topbar,
  .admin-content {
    padding-left: 16px;
    padding-right: 16px;
  }

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

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