:root {
  --ink: #243c34;
  --ink-deep: #183e34;
  --muted: #6f7d74;
  --faint: #a7afa2;
  --green: #2d6250;
  --green-soft: #eef3eb;
  --gold: #8a713a;
  --gold-soft: #f6f2e5;
  --red: #a35b45;
  --line: #e7ebe3;
  --canvas: #f6f7f3;
  --radius: 12px;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 14px; line-height: 1.5; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
button:disabled { cursor: wait; opacity: .6; }
:focus-visible { outline: 3px solid #bcaa76; outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 20; height: 52px; display: flex; align-items: center; gap: 28px; padding: 0 28px; background: var(--ink-deep); color: #d0ded4; }
.brand { color: #fff; font-size: 20px; font-weight: 600; letter-spacing: 3px; white-space: nowrap; }
.tabs { display: flex; gap: 6px; }
.tab { padding: 5px 14px; border-radius: 6px; color: #9fb5a6; white-space: nowrap; }
.tab:hover { color: #fff; }
.tab.active { background: rgb(255 255 255 / .13); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: 13px; }
.history-button { border: 1px solid #5d7a6b; border-radius: 6px; padding: 3px 12px; color: #d0ded4; white-space: nowrap; }
.history-button:hover { background: rgb(255 255 255 / .08); }
.session-dot { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.session-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #7b8f84; }
.session-dot.on::before { background: #a5bf8c; }

.history-panel { position: fixed; top: 58px; right: 20px; z-index: 30; width: min(360px, calc(100vw - 40px)); max-height: 70vh; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgb(30 50 40 / .14); padding: 6px; }
.history-row { width: 100%; display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 8px; text-align: left; }
.history-row:hover { background: var(--green-soft); }
.history-row time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.history-empty { padding: 14px; color: var(--muted); }

/* Layout */
.page { max-width: 1200px; margin: 0 auto; padding: 20px 28px 48px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.page-section { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
/* Wide tables scroll inside their card instead of stretching the page grid. */
.page > *, .page-section > *, .price-row > * { min-width: 0; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.muted { color: var(--muted); }

/* Controls */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 18px; border-radius: 8px; font-weight: 500; white-space: nowrap; }
.button.primary { background: #295641; color: #fff; }
.button.primary:hover { background: #1c4734; }
.button.ghost { border: 1px solid #d9e2d6; color: #50654f; background: #fff; min-height: 34px; padding: 5px 14px; }
.button.ghost:hover { background: #f5f7f0; }
.field-input { border: 1px solid #d9e2d6; border-radius: 6px; background: #fbfcf9; padding: 6px 10px; min-width: 0; }

/* Role input */
.input-card { display: flex; gap: 12px; align-items: center; padding: 12px; }
#role-input { flex: 1; min-width: 0; resize: none; height: 40px; border: 1px solid #d9e2d6; border-radius: 8px; background: #fbfcf9; padding: 9px 14px; line-height: 20px; }
#role-input:focus { outline: none; border-color: #819b7e; box-shadow: 0 0 0 3px rgb(118 144 101 / .12); }

.error-line { padding: 10px 14px; background: #fff4ed; border: 1px solid #f1dbca; border-radius: 8px; color: #966049; }
.status-line { color: var(--muted); font-size: 13px; }
.status-line.is-busy::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px; border: 2px solid #dbe5d2; border-top-color: #678b4f; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Summary card */
.head-card { padding: 18px 22px; display: grid; gap: 14px; }
.head-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 14px; }
.head-line h2 { font-size: 22px; font-weight: 600; }
.head-line .head-extra { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.head-link { color: var(--green); font-size: 13px; }
.head-link:hover { text-decoration: underline; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 4px 12px; border-radius: 6px; background: var(--green-soft); color: var(--green); font-size: 13px; }
.chip.plain { background: #f3f4f0; color: var(--muted); }
.chip.warn { background: var(--gold-soft); color: var(--gold); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 4px; background: var(--gold-soft); color: #9b8247; font-size: 12px; white-space: nowrap; vertical-align: 1px; }
.tag.soft { background: #f0f2ec; color: var(--muted); }

/* Prices */
.price-row { display: grid; grid-template-columns: 1fr 1fr .7fr; gap: 16px; }
.price-card { padding: 18px 22px; display: grid; align-content: start; gap: 6px; min-height: 140px; }
.price-card.primary { background: #214b3b; border-color: #214b3b; color: #f2f3d9; }
.price-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); }
.price-card.primary .price-label { color: #b4c7a5; }
.price-card.primary .tag { background: rgb(255 255 255 / .12); color: #d9caa0; }
.price-label.buy { color: var(--gold); }
.price-value { font-size: 34px; font-weight: 600; line-height: 1.25; letter-spacing: -.5px; }
.price-card.primary .price-value { font-size: 40px; }
.price-value.small { font-size: 28px; }
.price-value.empty { color: var(--faint); }
.price-card.primary .price-value.empty { color: #8fae9f; }
.price-sub { color: var(--muted); font-size: 13px; }
.price-card.primary .price-sub { color: #b4c7a5; }
.price-sub.up { color: var(--red); }
.price-sub.down { color: var(--green); }
.rule-inputs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; color: var(--muted); font-size: 13px; margin-top: 4px; }
.rule-inputs input { width: 48px; text-align: center; padding: 2px 4px; border: 1px solid #d9e2d6; border-radius: 5px; background: #fbfcf9; }

/* Lists */
.list-card { padding: 16px 20px 8px; }
.list-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.list-head h3 { font-size: 16px; font-weight: 600; }
.segment { display: inline-flex; gap: 4px; padding: 3px; border-radius: 8px; background: #f4f6ef; }
.segment button { padding: 4px 14px; border-radius: 6px; color: var(--muted); }
.segment button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgb(75 100 50 / .1); }
/* position: relative keeps the absolutely positioned .sr-only header inside the scroll box. */
.table-wrap { position: relative; overflow-x: auto; }
.list-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.list-table th { text-align: left; font-weight: 400; font-size: 12px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.list-table td { padding: 11px 10px; border-bottom: 1px solid #f0f2ec; vertical-align: middle; }
.list-table tr:last-child td { border-bottom: 0; }
.list-table .num { color: var(--faint); width: 32px; }
.list-table .price { font-weight: 600; white-space: nowrap; }
.list-table .link { text-align: right; white-space: nowrap; }
.list-table .link a { color: var(--green); }
.list-table .link a:hover { text-decoration: underline; }
.list-table tr.dim td { color: var(--faint); }
.list-table tr.dim .price { font-weight: 400; }
.delta-up { color: var(--green); }
.delta-down { color: var(--red); }
.list-empty { padding: 26px 10px 30px; text-align: center; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; background: #284c37; color: #f4f7ed; padding: 10px 18px; border-radius: 8px; box-shadow: 0 5px 25px rgb(32 51 31 / .2); max-width: calc(100vw - 30px); }

@media (max-width: 860px) {
  .topbar { gap: 14px; padding: 0 14px; }
  .brand { font-size: 17px; letter-spacing: 1px; }
  .tab { padding: 5px 9px; }
  .page { padding: 14px 14px 36px; gap: 12px; }
  .price-row { grid-template-columns: 1fr; }
  .price-card { min-height: 0; }
  .head-line .head-extra { margin-left: 0; width: 100%; }
}
@media (max-width: 480px) {
  .topbar { gap: 10px; padding: 0 10px; }
  .tab { padding: 5px 8px; font-size: 13px; }
  .topbar-right { gap: 8px; }
  /* Keep only the coloured dot for the session state on narrow screens. */
  .session-dot { font-size: 0; }
  #role-input { height: 60px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Login page and account bar of the shared deployment (GJ-017) */
.login-page { max-width: 420px; padding-top: 64px; }
.login-box { padding: 24px 28px; display: grid; gap: 10px; }
.login-box h1 { font-size: 20px; font-weight: 600; }
.login-form { display: grid; gap: 12px; margin-top: 6px; }
.login-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.login-form .field-input { font-size: 15px; color: var(--ink); padding: 8px 10px; }
.account-bar { display: inline-flex; align-items: center; gap: 8px; color: #d0ded4; white-space: nowrap; }
.account-bar button { border: 1px solid #5d7a6b; border-radius: 6px; padding: 2px 10px; color: #d0ded4; }
