:root {
  --bg: #ece4d6;
  --bg-2: #f7f1e6;
  --ink: #1c1712;
  --muted: #6a5f53;
  --line: #d8ccb8;
  --accent: #9a3412;
  --accent-soft: #f3e0d4;
  --teal: #0f5f57;
  --ok: #0f6b4c;
  --danger: #b42318;
  --warn: #92400e;
  --shadow: 0 18px 40px rgba(48, 32, 16, 0.08);
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --serif: "Songti SC", "Noto Serif SC", "STSong", "Iowan Old Style", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #f4e7c8 0%, transparent 50%),
    var(--bg);
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.rail {
  padding: 28px 22px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #fbf6ec 0%, #efe4d2 100%);
}
.brand { display: flex; gap: 12px; align-items: center; }
.stamp {
  width: 46px; height: 46px;
  border: 2px solid var(--accent);
  color: var(--accent);
  display: grid; place-items: center;
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: 0.04em;
  transform: rotate(-8deg);
  background: #fff8ef;
}
.brand-kicker {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.brand h1 {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
}
.brand-sub {
  margin: 16px 0 22px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}
.tabs { display: flex; flex-direction: column; gap: 6px; }
.tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  border-radius: 8px;
}
.tab:hover { background: rgba(255,255,255,0.5); }
.tab.is-active {
  background: #fff;
  border-color: var(--line);
  box-shadow: var(--shadow);
  font-weight: 600;
}
.rail-note {
  margin-top: 28px;
  padding: 14px;
  border: 1px dashed var(--accent);
  background: var(--accent-soft);
  font-size: 13px;
  line-height: 1.55;
}
.rail-note p { margin: 8px 0 0; color: var(--muted); }

main { padding: 24px 28px 48px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.topbar p { margin: 0; color: var(--muted); font-size: 13px; }
.pill {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #143c38;
  color: #e8fff8;
  white-space: nowrap;
}

.panel { display: none; }
.panel.is-active { display: block; }

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 22px 22px;
  box-shadow: var(--shadow);
}
.card h2, .card h3 {
  font-family: var(--serif);
  margin: 0 0 8px;
}
.lede { color: var(--muted); line-height: 1.65; margin: 0 0 16px; }
.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; }

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 12px 0 6px;
}
input, textarea, select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
textarea { min-height: 180px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
#order-note, #order-session-json { min-height: 72px; }
.row-actions, .note-row, .status-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.btn:hover { border-color: #b7a48c; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff8f3;
}
.btn.ghost { background: transparent; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #f3fff8; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.warn { background: #b45309; border-color: #b45309; color: #fff8ef; }

.error { color: var(--danger); font-size: 13px; margin: 10px 0 0; }
.empty { color: var(--muted); padding: 18px 4px; line-height: 1.6; }
.facts {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px 12px;
  margin: 0;
}
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0; word-break: break-all; }
.fingerprint { margin: 16px 0 8px; font-size: 13px; color: var(--muted); }
.hints, .warn-list { margin: 0; padding-left: 18px; line-height: 1.55; }
.warn-list { color: var(--warn); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.order-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.order-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  font: inherit;
}
.order-item:hover, .order-item.is-active { border-color: var(--accent); }
.order-item b { display: block; margin-bottom: 4px; }
.order-item span { color: var(--muted); font-size: 12px; }
.status {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #efe6d6;
}
.status.pending { background: #f3e0d4; color: var(--accent); }
.status.in_progress { background: #dceeea; color: var(--teal); }
.status.completed { background: #d9eee4; color: var(--ok); }
.status.failed { background: #f8d7d3; color: var(--danger); }
.status.cancelled { background: #ece8e1; color: var(--muted); }

.detail { margin-top: 16px; }
.timeline { margin: 0; padding-left: 18px; }
.timeline li { margin: 0 0 10px; line-height: 1.5; }
.timeline time { display: block; color: var(--muted); font-size: 12px; }

.cost-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 16px;
  align-items: end;
}
.cost-grid .btn { justify-self: start; margin-top: 18px; }
.hint-chip {
  display: inline-block;
  margin: 14px 0 0;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #efe6d6;
  color: var(--muted);
}
.cost-out {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.cost-out div {
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
.cost-out span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.cost-out strong { font-family: var(--serif); font-size: 28px; font-weight: 600; }

.checklist { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.checklist li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf8;
}
.checklist p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.checklist input { width: 18px; height: 18px; margin-top: 3px; }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); }
  .tabs { flex-direction: row; flex-wrap: wrap; }
  .split, .cost-grid, .cost-out { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr; }
  main { padding: 16px; }
}
