:root {
  --bg: #f5f7fb;
  --bg-soft: #f8fafc;
  --card: #ffffff;
  --border: #eef2f7;
  --border-strong: #e2e8f0;
  --text: #0f172a;
  --text-2: #1a2236;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --accent: #4c7dff;
  --accent-2: #7b5cff;
  --accent-grad: linear-gradient(135deg, #4c7dff, #7b5cff);
  --ok: #16a34a;
  --ok-bg: #ecfdf5;
  --warn: #f59e0b;
  --warn-bg: #fffbeb;
  --err: #dc2626;
  --err-bg: #fef2f2;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .04);
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
.muted { color: var(--muted); }
small.muted { font-weight: normal; font-size: .82em; }
code { background: #f1f5f9; padding: 0 .35em; border-radius: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; color: #334155; }

.container { max-width: 880px; margin: 0 auto; padding: 0 1rem; }

/* Header */
.site-header { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 14px 1rem; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent-grad); color: #fff; font-weight: 700; font-size: 13px;
  letter-spacing: .5px;
}
.brand-name { font-weight: 600; font-size: 1rem; color: var(--text-2); letter-spacing: .3px; }
.header-meta { display: flex; align-items: center; gap: 6px; font-size: .85rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); display: inline-block; }
.dot-ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, .15); }

/* Main */
.main { display: flex; flex-direction: column; gap: 1.25rem; padding: 1.5rem 1rem 2rem; }

/* Cards */
.card { background: var(--card); border-radius: var(--radius); padding: 1.4rem 1.4rem; box-shadow: var(--shadow); border: 1px solid var(--border); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.card-head h2, .card > h2 { margin: 0; font-size: 1.05rem; color: var(--text-2); font-weight: 600; }
.card > h2 { margin-bottom: 1rem; }
.link-btn { background: transparent; border: 0; color: var(--accent); cursor: pointer; font-size: .85rem; padding: 4px 8px; border-radius: 6px; }
.link-btn:hover { background: rgba(76, 125, 255, .08); }

/* Stock */
.stock-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stock-card {
  background: linear-gradient(180deg, #fff, #fafbfd);
  border: 1px solid var(--border-strong); border-radius: 10px;
  padding: .9rem 1rem;
}
.stock-card .lbl { font-size: .82rem; color: var(--muted); margin-bottom: 6px; }
.stock-card .val { font-size: 1.4rem; font-weight: 700; color: var(--text-2); letter-spacing: -.5px; }
.stock-card .sub { font-size: .75rem; color: var(--muted-2); margin-top: 4px; }
.stock-card.loading .val { color: var(--muted-2); font-weight: 500; font-size: 1rem; }
.stock-card.empty .val { color: var(--err); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: -.5rem -.4rem 1.2rem; padding: 0 .4rem; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: transparent; border: 0; padding: .8rem 1rem;
  color: var(--muted); font-size: .92rem; cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
  display: flex; align-items: center; gap: 6px; font-weight: 500;
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-icon { font-size: 1rem; }

/* Panels */
.panel { display: none; }
.panel.active { display: block; }
.panel-desc { font-size: .88rem; color: var(--muted); margin: 0 0 1.2rem; line-height: 1.6; }

/* Form */
.form { display: flex; flex-direction: column; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: .85rem; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.field-label em { color: var(--err); font-style: normal; }
.field input, .field select, .field textarea {
  font-family: inherit; font-size: .92rem;
  background: #fff; border: 1px solid var(--border-strong); color: var(--text);
  padding: .65rem .8rem; border-radius: var(--radius-sm); transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(76, 125, 255, .15);
}
.field textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; resize: vertical; min-height: 140px; }

.check { display: flex; align-items: flex-start; gap: 8px; font-size: .85rem; color: var(--muted); cursor: pointer; user-select: none; }
.check input { margin: 0; margin-top: 2px; accent-color: var(--accent); }

.primary-btn {
  background: var(--accent-grad); color: #fff; border: 0;
  padding: .85rem 1rem; border-radius: var(--radius-sm);
  font-size: .98rem; font-weight: 600; cursor: pointer; font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .1s, box-shadow .15s;
  box-shadow: 0 4px 12px rgba(76, 125, 255, .25);
}
.primary-btn:hover { box-shadow: 0 6px 18px rgba(76, 125, 255, .35); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn:disabled { background: #cbd5e1; color: #fff; cursor: not-allowed; box-shadow: none; }
.btn-icon { font-size: 1.05rem; line-height: 1; }

/* Status section */
.status-section { border-left: 4px solid var(--accent); }
.status-section.success { border-left-color: var(--ok); background: var(--ok-bg); }
.status-section.failed { border-left-color: var(--err); background: var(--err-bg); }
.status-section.pending { border-left-color: var(--warn); }
.badge {
  display: inline-flex; align-items: center; padding: .2rem .7rem;
  font-size: .78rem; border-radius: 999px; font-weight: 600;
  background: #f1f5f9; color: var(--muted);
}
.badge.pending { background: var(--warn-bg); color: var(--warn); }
.badge.success { background: var(--ok-bg); color: var(--ok); }
.badge.failed { background: var(--err-bg); color: var(--err); }

.status-body p { margin: 0; font-size: .92rem; }
.order-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 16px; margin-top: 1rem; }
.order-grid .item { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: .7rem .9rem; }
.order-grid .item .k { font-size: .72rem; color: var(--muted); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .5px; }
.order-grid .item .v { font-size: .9rem; color: var(--text-2); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }

/* Result card (CDK query) */
.result-card { margin-top: 1rem; padding: 1rem; background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .88rem; }
.result-card .row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.result-card .row:last-child { border-bottom: 0; }
.result-card .row .k { color: var(--muted); }
.result-card .row .v { color: var(--text-2); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; text-align: right; word-break: break-all; max-width: 60%; }
.result-card .err-line { color: var(--err); }

/* Guide */
.guide-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.guide-col { padding: 1rem; background: var(--bg-soft); border-radius: 10px; border: 1px solid var(--border); }
.guide-col h3 { margin: 0 0 6px; font-size: .95rem; color: var(--accent); }
.guide-col p { margin: 0; font-size: .85rem; line-height: 1.65; color: var(--muted); }

/* FAQ */
.faq-section details {
  border: 1px solid var(--border); border-radius: 10px;
  padding: .85rem 1rem; margin-bottom: 8px; background: #fff;
}
.faq-section details[open] { background: var(--bg-soft); }
.faq-section summary {
  cursor: pointer; font-size: .92rem; color: var(--text-2); font-weight: 500;
  list-style: none; display: flex; align-items: center; justify-content: space-between;
}
.faq-section summary::-webkit-details-marker { display: none; }
.faq-section summary::after { content: '+'; font-size: 1.2rem; color: var(--muted-2); transition: transform .15s; }
.faq-section details[open] summary::after { content: '−'; }
.faq-section details p { margin: .7rem 0 0; font-size: .85rem; color: var(--muted); line-height: 1.6; }

/* Footer */
.site-footer { padding: 2rem 0; }
.site-footer p { margin: 0; text-align: center; font-size: .8rem; }

/* Responsive */
@media (max-width: 640px) {
  .header-inner { padding: 12px 1rem; }
  .brand-name { font-size: .95rem; }
  .card { padding: 1.1rem 1rem; }
  .stock-grid { grid-template-columns: 1fr 1fr; }
  .stock-grid .stock-card:nth-child(3) { grid-column: span 2; }
  .guide-grid { grid-template-columns: 1fr; }
  .tab { padding: .75rem .8rem; font-size: .88rem; }
}
