:root {
  --bg: #f5f1e8;
  --panel: rgba(255, 252, 245, 0.92);
  --panel-strong: #fffaf1;
  --line: #dacfbf;
  --line-strong: #bcae9a;
  --text: #2d2923;
  --muted: #6d6458;
  --accent: #145b73;
  --accent-strong: #0b4052;
  --accent-soft: rgba(20, 91, 115, 0.1);
  --warm: #c57b39;
  --danger: #a33d32;
  --shadow: 0 18px 50px rgba(80, 60, 30, 0.1);
  --radius: 22px;
  --radius-sm: 14px;
  --font-display: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-display);
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(197, 123, 57, 0.18), transparent 28%),
    radial-gradient(circle at bottom left, rgba(20, 91, 115, 0.15), transparent 24%),
    linear-gradient(180deg, #fbf7ef 0%, var(--bg) 100%);
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  width: min(1460px, calc(100% - 32px));
  margin: 28px auto 40px;
}

.hero,
.panel {
  border: 1px solid rgba(188, 174, 154, 0.55);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 30px;
  margin-bottom: 22px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 6px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  font-weight: 700;
}

.hero h1,
.panel h2 {
  margin: 0;
  line-height: 1.05;
}

.hero h1 {
  font-size: clamp(30px, 4vw, 46px);
}

.panel h2 {
  font-size: 24px;
}

.hero-copy {
  max-width: 760px;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  min-width: 220px;
}

.layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 22px;
}

.span-2 {
  grid-column: 1 / -1;
}

.panel {
  padding: 24px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.panel-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  text-align: right;
  color: var(--muted);
  font-size: 14px;
}

.panel-tools {
  gap: 12px;
  flex-wrap: wrap;
}

.cloud-status {
  padding: 6px 10px;
  border: 1px solid rgba(188, 174, 154, 0.6);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.cloud-status.is-error {
  color: var(--danger);
  border-color: rgba(163, 61, 50, 0.28);
}

.period-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
  align-items: start;
}

.field-stack {
  display: flex;
  flex-direction: column;
  align-self: start;
  min-width: 0;
  gap: 8px;
}

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

.field-stack span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 0;
}

input,
select {
  width: 100%;
  min-height: 44px;
  height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  line-height: 1.2;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.select-shell {
  position: relative;
}

.select-shell::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  width: 10px;
  height: 6px;
  transform: translateY(-50%);
  pointer-events: none;
  background: linear-gradient(135deg, transparent 50%, var(--muted) 50%) left,
    linear-gradient(225deg, transparent 50%, var(--muted) 50%) right;
  background-size: 50% 100%;
  background-repeat: no-repeat;
}

.select-shell select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 40px;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

button {
  min-height: 44px;
  height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

button:hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent) 0%, #1d809b 100%);
  color: #fff;
  box-shadow: 0 12px 24px rgba(20, 91, 115, 0.18);
}

.ghost-btn,
.text-btn,
.danger-btn {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

.danger-btn {
  color: var(--danger);
  border-color: rgba(163, 61, 50, 0.28);
}

.text-btn {
  min-height: 36px;
  height: 36px;
  padding-inline: 14px;
}

.field-button {
  display: flex;
  align-items: center;
  width: 100%;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  box-shadow: none;
}

.field-button:hover {
  transform: none;
}

.field-button:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(188, 174, 154, 0.5);
  border-radius: 18px;
}

.billing-table {
  width: 100%;
  min-width: 1280px;
  border-collapse: collapse;
  background: rgba(255, 250, 241, 0.95);
}

.billing-table th,
.billing-table td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(188, 174, 154, 0.45);
  border-right: 1px solid rgba(188, 174, 154, 0.35);
  text-align: center;
  vertical-align: middle;
  font-size: 14px;
}

.billing-table th {
  position: sticky;
  top: 0;
  background: rgba(226, 218, 202, 0.95);
  z-index: 1;
  color: #4d4439;
}

.billing-table th.two-line-header {
  white-space: nowrap;
}

.billing-table th.two-line-header span {
  display: block;
  white-space: nowrap;
}

.billing-table th.col-shared-fee,
.billing-table td:nth-child(9) {
  min-width: 64px;
}

.billing-table th.col-amount-due,
.billing-table td:nth-child(10) {
  min-width: 178px;
}

.billing-table td:last-child,
.billing-table th:last-child {
  border-right: none;
}

.billing-table tfoot td {
  font-weight: 700;
  background: rgba(20, 91, 115, 0.08);
}

.readonly-cell {
  background: rgba(255, 255, 255, 0.64);
  color: #463e34;
}

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

.status-good {
  color: #1c6b43;
  font-weight: 700;
}

.status-warn {
  color: var(--danger);
  font-weight: 700;
}

.hint-text {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.hint-text.is-error {
  color: var(--danger);
}

.tier-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tier-item {
  display: grid;
  grid-template-columns: 1.1fr 1fr auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid rgba(188, 174, 154, 0.5);
  border-radius: 16px;
  background: var(--panel-strong);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.history-card {
  border: 1px solid rgba(188, 174, 154, 0.48);
  border-radius: 18px;
  background: var(--panel-strong);
  overflow: hidden;
}

.history-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  cursor: pointer;
  list-style: none;
}

.history-summary-row::-webkit-details-marker {
  display: none;
}

.history-title-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-title {
  font-size: 18px;
}

.history-date,
.history-amounts {
  color: var(--muted);
  font-size: 14px;
}

.history-body {
  padding: 0 18px 18px;
}

.history-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0 0 12px;
}

.empty-state {
  padding: 28px;
  border: 1px dashed rgba(188, 174, 154, 0.8);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.55);
}

.modal-shell[hidden] {
  display: none;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 30;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(45, 41, 35, 0.38);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  width: min(860px, calc(100% - 24px));
  max-height: calc(100vh - 48px);
  margin: 24px auto;
  padding: 24px;
  overflow: auto;
  border: 1px solid rgba(188, 174, 154, 0.55);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.github-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
}

.github-token-field {
  grid-column: 1 / -1;
}

.github-actions {
  gap: 10px;
  flex-wrap: wrap;
}

.help-list {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
  line-height: 1.8;
}

.help-list li + li {
  margin-top: 6px;
}

.help-list strong {
  color: var(--accent-strong);
}

.stacked-number {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stacked-number small {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1120px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .hero {
    flex-direction: column;
  }

  .hero-actions {
    min-width: 0;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 20px, 100%);
    margin-top: 16px;
  }

  .hero,
  .panel {
    padding: 18px;
    border-radius: 18px;
  }

  .period-grid,
  .tier-item,
  .github-grid {
    grid-template-columns: 1fr;
  }

  .panel-header,
  .history-summary-row,
  .history-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-meta {
    justify-content: flex-start;
    text-align: left;
  }
}
