:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #d9e0ea;
  --line-soft: #edf1f6;
  --text: #172033;
  --muted: #697386;
  --brand: #2563eb;
  --brand-deep: #1d4ed8;
  --brand-soft: #eff6ff;
  --success: #168a54;
  --warning: #b7791f;
  --danger: #cf2e2e;
  --nav: #111827;
  --nav-2: #172033;
  --nav-muted: #a7b0c0;
}

html,
body,
#root {
  min-height: 100%;
}

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

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.10), transparent 34%),
    linear-gradient(315deg, rgba(22, 138, 84, 0.10), transparent 30%),
    #eef3f8;
}

.login-panel {
  width: min(430px, 100%);
  background: var(--panel);
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: 8px;
  padding: 30px;
  box-shadow: 0 22px 54px rgba(15, 23, 42, 0.14);
}

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

.login-mark {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 24px;
  background: linear-gradient(135deg, var(--brand), #16a34a);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.22);
}

.login-title {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 750;
  line-height: 1.25;
}

.login-subtitle {
  margin: 0;
  color: var(--muted);
}

.login-panel .ant-form-item {
  margin-bottom: 18px;
}

.login-panel .ant-input-affix-wrapper,
.login-panel .ant-input {
  border-radius: 8px;
}

.captcha-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 10px;
  align-items: start;
}

.captcha-input input {
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 700;
}

.captcha-image-button {
  height: 40px;
  width: 132px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  overflow: hidden;
  color: var(--muted);
}

.captcha-image-button:hover {
  border-color: var(--brand);
}

.captcha-image-button:disabled {
  cursor: wait;
  opacity: 0.75;
}

.captcha-image-button img {
  display: block;
  width: 132px;
  height: 46px;
  transform: translateY(-3px);
}

.login-submit {
  height: 42px;
  border-radius: 8px;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
}

.app-shell {
  min-height: 100vh;
  background: var(--bg);
}

.app-shell .ant-layout-sider {
  background: linear-gradient(180deg, var(--nav) 0, var(--nav-2) 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 8px 0 28px rgba(15, 23, 42, 0.12);
}

.app-logo {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  color: #fff;
  font-weight: 750;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  letter-spacing: 0;
}

.app-logo::before {
  content: "C";
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  font-weight: 800;
}

.app-shell .ant-menu-dark {
  background: transparent;
  padding: 10px 0;
}

.app-shell .ant-menu-dark .ant-menu-item {
  height: 42px;
  margin: 5px 10px;
  width: calc(100% - 20px);
  border-radius: 8px;
  color: var(--nav-muted);
}

.app-shell .ant-menu-dark .ant-menu-item .anticon {
  font-size: 16px;
}

.app-shell .ant-menu-dark .ant-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.app-shell .ant-menu-dark .ant-menu-item-selected {
  background: #2458cf;
  color: #fff;
  border-radius: 6px;
  box-shadow: none;
}

.topbar {
  height: 64px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  backdrop-filter: blur(10px);
}

.topbar .ant-typography {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
}

.content {
  padding: 24px;
}

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

.toolbar h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 760;
  color: var(--text);
}

.toolbar .ant-space {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stats-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.stat-card {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--brand), #16a34a);
}

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

.stat-value {
  margin-top: 8px;
  font-size: 30px;
  font-weight: 760;
  line-height: 1;
}

.table-panel,
.settings-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

.table-panel .ant-table-wrapper .ant-table {
  color: var(--text);
}

.table-panel .ant-table-container {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  overflow: hidden;
}

.table-panel .ant-table-thead > tr > th {
  background: #f6f8fb;
  color: #354054;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table-panel .ant-table-thead > tr > th .ant-table-column-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-panel .ant-table-thead .ant-table-column-sorters,
.table-panel .ant-table-thead .ant-table-filter-column {
  flex-wrap: nowrap;
}

.table-panel .ant-table-thead > tr > th.ant-table-column-sort {
  background: #eef4ff;
}

.table-panel .ant-table-tbody > tr > td {
  border-bottom: 1px solid var(--line-soft);
}

.table-panel .ant-table-tbody > tr:hover > td {
  background: #f8fbff;
}

.table-panel .ant-table-tbody > tr.ant-table-row-selected > td {
  background: #eff6ff;
}

.table-panel .ant-pagination {
  margin-bottom: 0;
}

.ant-btn {
  border-radius: 8px;
  box-shadow: none;
}

.ant-btn-primary {
  background: var(--brand);
}

.ant-btn-primary:hover {
  background: var(--brand-deep) !important;
}

.ant-modal-content,
.ant-modal-header {
  border-radius: 8px !important;
}

.ant-input,
.ant-input-affix-wrapper,
.ant-input-number,
.ant-select-selector,
.ant-picker {
  border-radius: 8px !important;
}

.ant-tag {
  border-radius: 8px;
  margin-inline-end: 4px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 16px;
}

.lab-create-panel {
  margin-bottom: 16px;
}

.lab-mode-hint {
  margin-top: 10px;
  color: var(--muted, #64748b);
  font-size: 13px;
  line-height: 1.5;
}

.lab-create-panel .ant-form {
  row-gap: 12px;
}

.lab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.lab-task-card,
.lab-empty {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

.lab-task-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.lab-task-title {
  font-size: 16px;
  font-weight: 750;
  color: var(--text);
}

.lab-task-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.lab-run-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: max-content;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.lab-run-state::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
}

.lab-run-state.running::before {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(22, 138, 84, 0.12);
}

.lab-run-state.cooling::before {
  background: var(--warning);
  box-shadow: 0 0 0 4px rgba(183, 121, 31, 0.12);
}

.lab-run-state.error::before {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(207, 46, 46, 0.12);
}

.lab-run-state.done::before {
  background: var(--brand);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.lab-task-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.lab-task-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lab-task-error {
  margin-top: 12px;
  padding: 9px 10px;
  background: #fff1f0;
  border: 1px solid #ffccc7;
  border-radius: 8px;
  color: var(--danger);
  font-size: 12px;
}

.lab-task-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.lab-empty {
  color: var(--muted);
  text-align: center;
}

.stacked-panel {
  margin-top: 16px;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 48px;
  font-weight: 600;
}

.status-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
  box-shadow: 0 0 0 3px rgba(105, 115, 134, 0.14);
}

.status-dot.active::before,
.status-dot.online::before {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(22, 138, 84, 0.15);
}

.status-dot.disabled::before,
.status-dot.offline::before {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(207, 46, 46, 0.14);
}

@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content {
    padding: 14px;
  }

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

  .toolbar .ant-space {
    justify-content: flex-start;
  }
}

@media (max-width: 460px) {
  .login-panel {
    padding: 22px;
  }

  .login-brand {
    align-items: flex-start;
  }

  .captcha-row {
    grid-template-columns: 1fr;
  }

  .captcha-image-button,
  .captcha-image-button img {
    width: 100%;
  }
}

.legacy-fetch-count-only .ant-form-item:nth-child(n + 2) {
  display: none;
}

.usage-quota-loading {
  padding: 28px 8px;
  text-align: center;
  color: var(--muted);
}

.usage-quota-tags {
  margin-bottom: 14px;
}

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

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

.usage-quota-stat .label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.usage-quota-stat .value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 8px;
}

.usage-quota-meta {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

@media (max-width: 560px) {
  .usage-quota-grid {
    grid-template-columns: 1fr;
  }
}
