:root {
  color-scheme: dark;
  --bg: #050403;
  --panel: #0c0a08;
  --side: #1d1916;
  --card: #1f1a16;
  --card-deep: #130f0d;
  --line: #2d251f;
  --line-soft: #211b17;
  --text: #e7ded2;
  --muted: #867c71;
  --gold: #f5aa24;
  --gold-deep: #4a2d12;
  --green: #48d283;
  --green-deep: #082415;
  --pink: #d98a97;
  --danger: #e86c5d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.admin-shell {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--side);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 82px;
  padding: 18px 14px;
  border-bottom: 1px solid var(--line);
}

.brand__mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--gold);
  background: #4a321b;
  font-weight: 900;
}

.brand strong {
  display: block;
  color: var(--gold);
  font-size: 17px;
}

.brand span,
.sidebar-foot span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 6px;
  padding: 18px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  color: #c7bdb2;
  text-decoration: none;
  font-weight: 700;
}

.nav-item span {
  width: 18px;
  color: #9f978d;
}

.nav-item.is-active,
.nav-item:hover {
  color: var(--gold);
  background: var(--gold-deep);
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.sidebar-foot button {
  margin-top: 8px;
  border: 0;
  padding: 0;
  color: #b8afa6;
  background: transparent;
}

.main-panel {
  min-width: 0;
  padding: 28px 24px 36px;
  background: linear-gradient(180deg, #080706, var(--bg) 260px);
}

.topbar,
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2 {
  margin-bottom: 0;
  color: var(--gold);
  font-size: 24px;
  letter-spacing: 0;
}

.ghost-button,
.icon-button,
.result-actions button,
.order-tabs button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: #d2c8bd;
  background: #0d0b0a;
}

.ghost-button:hover,
.icon-button:hover,
.result-actions button:hover,
.order-tabs button:hover {
  border-color: var(--gold-deep);
  color: var(--gold);
}

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

.metric-card {
  min-height: 104px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}

.metric-card--income {
  border-color: #4b2a17;
  background: linear-gradient(145deg, #20120d, #1d1511);
}

.metric-card--green {
  border-color: #124b2b;
  background: linear-gradient(145deg, #061a10, #0f1d14);
}

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

.metric-card strong {
  display: block;
  margin-top: 8px;
  color: #eadfd2;
  font-size: 30px;
  line-height: 1;
}

.metric-card--income strong {
  color: var(--gold);
}

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

.metric-card small {
  display: block;
  margin-top: 10px;
  color: #685f57;
}

.work-grid {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.console-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-deep);
}

.divination-form,
.result,
.history {
  padding: 18px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--green);
  background: #0b2a19;
  font-size: 12px;
  font-weight: 800;
}

.field {
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}

label,
legend {
  display: block;
  margin-bottom: 9px;
  color: #c7bdb2;
  font-weight: 800;
}

textarea {
  width: 100%;
  min-height: 116px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  color: var(--text);
  background: #0a0807;
  line-height: 1.65;
  outline: none;
}

textarea:focus {
  border-color: var(--gold-deep);
  box-shadow: 0 0 0 3px rgba(245, 170, 36, 0.08);
}

.field__meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.category-grid label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #bdb3a7;
  background: #0b0908;
  font-weight: 800;
}

.category-grid input {
  position: absolute;
  opacity: 0;
}

.category-grid label:has(input:checked) {
  color: var(--gold);
  border-color: var(--gold-deep);
  background: #3a220e;
}

.cast-area {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.cast-board {
  display: flex;
  flex-direction: column-reverse;
  justify-content: center;
  gap: 8px;
  min-height: 190px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #080605;
}

.empty-line,
.muted {
  color: var(--muted);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.primary-action,
.secondary-action {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 900;
}

.primary-action {
  color: #1b1107;
  background: var(--gold);
}

.secondary-action {
  color: #07150d;
  background: var(--green);
}

.secondary-action:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.yao {
  display: grid;
  grid-template-columns: 48px 1fr 68px;
  align-items: center;
  gap: 10px;
  min-height: 22px;
  color: var(--muted);
  font-size: 12px;
}

.yao__line {
  display: flex;
  gap: 10px;
  align-items: center;
}

.yao__bar {
  height: 8px;
  flex: 1;
  border-radius: 999px;
  background: var(--green);
}

.yao--yin .yao__bar {
  background: var(--gold);
}

.yao--moving .yao__status {
  color: var(--pink);
  font-weight: 900;
}

.icon-button {
  width: 40px;
  padding: 0;
  color: var(--gold);
  font-size: 20px;
}

.hexagram-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 12px;
}

.hexagram-card {
  min-height: 128px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}

.hexagram-card span {
  color: var(--muted);
  font-size: 12px;
}

.hexagram-card strong {
  display: block;
  margin: 7px 0;
  color: var(--gold);
  font-size: 48px;
  line-height: 1;
}

.hexagram-card p {
  margin: 0;
  color: #e7ded2;
  font-weight: 900;
}

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

.reading-grid section,
.moving-lines {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b0908;
}

.reading-grid h3,
.moving-lines h3 {
  margin-bottom: 7px;
  color: var(--gold);
  font-size: 14px;
}

.reading-grid p,
.moving-lines p {
  margin-bottom: 0;
  color: #cfc4b9;
  line-height: 1.75;
}

.moving-lines {
  margin-top: 10px;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.feedback {
  display: flex;
  gap: 8px;
}

.disclaimer {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.history {
  margin-top: 14px;
}

.order-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 12px;
}

.order-tabs button {
  min-height: 34px;
  border-radius: 999px;
}

.order-tabs .is-active {
  color: #1b1107;
  border-color: var(--gold);
  background: var(--gold);
}

.history-list {
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.history-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

.history-table th,
.history-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}

.history-table th {
  color: var(--muted);
  background: #1c1714;
  font-size: 13px;
}

.history-table td {
  color: #cfc4b9;
}

.history-table strong {
  display: block;
  color: #e4dbcf;
}

.history-table small {
  color: var(--muted);
}

.amount {
  color: var(--gold);
  font-size: 22px;
  font-weight: 900;
}

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

.paid {
  color: var(--green);
  background: #0b2a19;
}

.pending {
  color: var(--gold);
  background: #3a220e;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(24px);
  max-width: min(460px, calc(100% - 32px));
  padding: 12px 16px;
  border-radius: 8px;
  color: #f4eadf;
  background: rgba(31, 26, 22, 0.96);
  border: 1px solid var(--line);
  opacity: 0;
  pointer-events: none;
  transition: 0.24s ease;
}

.toast.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

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

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

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .main-panel {
    padding: 20px 12px 28px;
  }

  .metric-grid,
  .work-grid,
  .reading-grid,
  .hexagram-pair {
    grid-template-columns: 1fr;
  }

  .result {
    grid-column: auto;
  }
}
