:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f9fbfd;
  --ink: #172033;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #e4e7ec;
  --line-strong: #cfd6df;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eef4ff;
  --green: #0f9f6e;
  --green-soft: #e9f8f1;
  --red: #d92d20;
  --red-soft: #fff1f0;
  --amber: #b7791f;
  --amber-soft: #fff7df;
  --shadow: 0 18px 50px rgba(23, 32, 51, 0.09);
  --radius: 8px;
  --font: "Microsoft YaHei", "PingFang SC", "HarmonyOS Sans SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(180deg, #fbfcfe 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: var(--font);
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.app-shell,
.manager-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.customer-layout {
  display: grid;
  grid-template-columns: minmax(0, 640px) minmax(280px, 340px);
  align-items: start;
  gap: 22px;
}

.hero-card,
.notice-card,
.guide-card,
.manager-card,
.table-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 30px;
}

.hero-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  color: #fff;
  background: var(--primary);
  font-size: 24px;
  font-weight: 900;
}

.hero-head h1,
.manager-title h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
  font-weight: 900;
}

.hero-head p,
.manager-title p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.cert-form,
.manager-form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.field input,
.query-row input,
.toolbar input,
.manager-form input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #fff;
  color: var(--ink);
  padding: 13px 14px;
  font-size: 15px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.field input:focus,
.query-row input:focus,
.toolbar input:focus,
.manager-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.field input::placeholder,
.query-row input::placeholder,
.toolbar input::placeholder,
.manager-form input::placeholder {
  color: #a5adba;
}

.input-with-button,
.query-row,
.toolbar,
.manager-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.input-with-button input {
  flex: 1;
}

.primary-button,
.secondary-button,
.mini-button,
.plain-button,
.small-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 900;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.primary-button {
  min-height: 52px;
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
  font-size: 16px;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.2);
}

.secondary-button,
.mini-button,
.plain-button {
  min-height: 46px;
  padding: 0 16px;
  color: var(--primary);
  background: #fff;
}

.mini-button {
  min-width: 68px;
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.plain-button {
  color: var(--muted);
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 12px;
}

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

.primary-button:hover,
.secondary-button:hover,
.mini-button:hover,
.plain-button:hover,
.small-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(23, 32, 51, 0.1);
}

.help-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.help-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid #c9d7f5;
  border-radius: 8px;
  padding: 0 14px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  text-decoration: none;
  font-size: 14px;
  font-weight: 900;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.help-link:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
  box-shadow: 0 8px 20px rgba(23, 32, 51, 0.1);
}

.security-reminder {
  margin: 12px 0 0;
  color: var(--red);
  font-size: 14px;
  font-weight: 900;
}

.status-section {
  margin-top: 26px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-heading h2,
.notice-title h2,
.manager-card h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
}

.query-row input {
  width: 210px;
}

.status-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface-soft);
}

.status-panel.empty-state {
  min-height: 90px;
  display: grid;
  place-items: center;
  color: var(--faint);
  text-align: center;
}

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

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

.status-main span,
.status-detail span {
  color: var(--muted);
  font-size: 13px;
}

.status-main strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 20px;
}

.status-panel.status-success .order-status-text {
  color: var(--green);
}

.status-panel.status-failed .order-status-text,
.status-panel.status-canceled .order-status-text {
  color: var(--red);
}

.status-panel.status-running .order-status-text {
  color: var(--primary-dark);
}

.progress-track {
  width: 100%;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  margin: 14px 0 12px;
  background: #e9edf3;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.status-panel.status-success .progress-track span {
  background: var(--green);
}

.status-panel.status-failed .progress-track span,
.status-panel.status-canceled .progress-track span {
  background: var(--red);
}

.status-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.live-progress-detail {
  width: 100%;
  color: var(--primary-dark) !important;
  font-weight: 900;
}

.status-panel.status-success .live-progress-detail {
  color: var(--green) !important;
}

.status-panel.status-failed .live-progress-detail,
.status-panel.status-canceled .live-progress-detail {
  color: var(--red) !important;
}

.live-dots {
  display: inline-block;
  min-width: 1.6em;
  color: inherit !important;
  text-align: left;
}

.side-column {
  position: sticky;
  top: 20px;
  display: grid;
  gap: 16px;
}

.notice-card,
.guide-card {
  overflow: hidden;
}

.notice-title,
.guide-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
}

.notice-title {
  background: var(--amber-soft);
}

.notice-title span {
  color: var(--amber);
  font-weight: 900;
}

.guide-title {
  background: var(--primary-soft);
}

.guide-title span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
  background: var(--primary);
  font-weight: 900;
}

.guide-title h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
}

.notice-card ul {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 18px 20px 22px 32px;
  color: #475467;
  line-height: 1.62;
  font-size: 14px;
}

.notice-card strong {
  color: #a9271f;
}

.guide-card ol {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 18px 20px 22px 38px;
  color: #475467;
  line-height: 1.62;
  font-size: 14px;
}

.guide-card li::marker {
  color: var(--primary);
  font-weight: 900;
}

.guide-card strong {
  color: var(--primary-dark);
}

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
}

.toast {
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 14px;
}

.toast.error {
  border-left-color: var(--red);
}

.toast.warn {
  border-left-color: var(--amber);
}

.is-loading {
  pointer-events: none;
}

.is-loading::after {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 10px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  vertical-align: -2px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.manager-shell {
  display: grid;
  gap: 18px;
}

.manager-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.report-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  background: var(--surface);
}

.report-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.report-card strong {
  display: block;
  margin-top: 7px;
  font-size: 28px;
  line-height: 1;
}

.report-card.good strong {
  color: var(--green);
}

.report-card.warn strong {
  color: var(--amber);
}

.manager-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  gap: 18px;
}

.manager-card,
.table-panel {
  padding: 20px;
}

.manager-card header,
.table-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.manager-card header p,
.table-panel header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.manager-form {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.manager-actions {
  flex-wrap: wrap;
}

.compact-actions {
  justify-content: flex-end;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

.data-table th {
  color: var(--muted);
  background: var(--surface-soft);
  font-weight: 900;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.mono {
  font-family: var(--mono);
  overflow-wrap: anywhere;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 900;
}

.pill.available,
.pill.success,
.pill.active {
  color: var(--green);
  background: var(--green-soft);
}

.pill.used,
.pill.failed,
.pill.canceled,
.pill.disabled,
.pill.exhausted {
  color: var(--red);
  background: var(--red-soft);
}

.pill.running {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.empty-cell {
  color: var(--faint);
  text-align: center;
}

.admin-key-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 14px;
}

.admin-key-box strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-family: var(--mono);
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  .customer-layout,
  .manager-grid {
    grid-template-columns: 1fr;
  }

  .side-column {
    position: static;
    order: -1;
  }

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

@media (max-width: 640px) {
  .app-shell,
  .manager-shell {
    padding: 12px 12px 32px;
  }

  .hero-card,
  .manager-card,
  .table-panel {
    padding: 20px;
  }

  .hero-head,
  .manager-title,
  .section-heading,
  .input-with-button,
  .query-row,
  .toolbar,
  .manager-card header,
  .table-panel header {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-head h1,
  .manager-title h1 {
    font-size: 24px;
  }

  .query-row input,
  .query-row button,
  .mini-button,
  .secondary-button,
  .primary-button,
  .plain-button,
  .help-link {
    width: 100%;
  }

  .status-main,
  .report-grid {
    grid-template-columns: 1fr;
  }
}
