:root {
  color-scheme: light;
  --page: #f7f9fd;
  --sheet: #fff;
  --ink: #142139;
  --muted: #52627b;
  --line: #e2e8f1;
  --accent: #174fc0;
  --accent-deep: #123b90;
  --soft: #edf4ff;
  --warn: #855414;
  --warn-soft: #fff3de;
  --good: #146649;
  --good-soft: #e9f5ee;
  --bad: #a42530;
  --bad-soft: #fff0f1;
  --radius: 13px;
  --font: Inter, system-ui, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font: 15px/1.5 var(--font); }
[hidden] { display: none !important; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1 { font-size: clamp(1.65rem, 3vw, 2.3rem); letter-spacing: -.035em; line-height: 1.2; }
h2 { font-size: 1.04rem; line-height: 1.3; }
h3 { font-size: .99rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid #3772e2; outline-offset: 2px; }
.skip-link { position: fixed; inset: 12px auto auto 12px; z-index: 30; transform: translateY(-160%); background: var(--accent-deep); color: #fff; padding: 8px 14px; border-radius: 6px; }
.skip-link:focus { transform: none; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font-size: .88rem; font-weight: 630; text-decoration: none; white-space: nowrap; }
.button:hover { background: var(--soft); border-color: #cadaf7; text-decoration: none; }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.primary:hover { background: var(--accent-deep); }
.button.text { background: transparent; border-color: transparent; color: var(--accent); padding-inline: 8px; }
.button.danger { color: var(--bad); }
.button[disabled] { opacity: .55; cursor: not-allowed; }
.button.small { min-height: 30px; padding: 4px 9px; font-size: .82rem; }
input, select, textarea { min-width: 0; padding: 8px 9px; border: 1px solid #d7dfed; border-radius: 7px; color: var(--ink); background: #fff; }
textarea { min-height: 105px; resize: vertical; }
input[readonly] { background: var(--page); }
input[disabled], select[disabled] { color: var(--muted); background: var(--page); }
label { display: grid; gap: 6px; font-size: .88rem; color: var(--muted); font-weight: 620; }
label small { font-weight: 400; }
.eyebrow { font-size: .8rem; letter-spacing: .11em; font-weight: 660; display: block; margin-bottom: 8px; }
.login { min-height: min(780px, 100dvh); display: grid; grid-template-columns: 1fr 1fr; background: var(--sheet); }
.login-side { min-height: 100%; display: grid; align-content: space-between; gap: 50px; padding: clamp(24px, 7vw, 95px); background: #143677; color: #fff; }
.login-side h1 { font-size: clamp(2rem, 5vw, 4rem); margin-top: 10px; }
.login-brand { display: flex; gap: 12px; align-items: center; color: #fff; font-weight: 690; }
.login-side .brand-mark { background: #fff; color: #174591; }
.login-side .eyebrow, .login-side p { color: #d1e1ff; }
.login-rule { width: 55px; height: 3px; margin: 26px 0 15px; background: #8cb3fb; }
.login-main { display: grid; place-items: center; padding: 32px 22px; }
.login-main form { display: grid; gap: 16px; width: min(100%, 330px); }
.login-main h2 { font-size: 1.7rem; }
.login-main p { color: var(--muted); margin-top: -10px; }
.login-main .primary { margin-top: 4px; }
.splash { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--muted); }
.workspace { min-height: 100dvh; display: grid; grid-template-columns: 200px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 24px; padding: 22px 13px 15px; border-right: 1px solid var(--line); background: #fff; }
.brand { display: flex; gap: 9px; align-items: center; margin: 0 4px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { flex: 0 0 34px; display: inline-grid; width: 34px; height: 34px; place-items: center; border-radius: 9px; color: #fff; background: var(--accent-deep); font-size: 1.17rem; font-weight: 690; }
.brand strong { display: block; line-height: 1.15; letter-spacing: .02em; }
.brand small { display: block; color: var(--muted); margin-top: 3px; font-size: .73rem; }
.nav, .connections { display: grid; align-content: start; gap: 4px; }
.nav a, .connections a { display: flex; gap: 9px; align-items: center; color: var(--muted); border-radius: 7px; padding: 8px 9px; min-height: 42px; font-size: .88rem; font-weight: 630; text-decoration: none; }
.nav a:hover, .connections a:hover { background: #f1f5fc; color: var(--accent); }
.nav a[aria-current="page"] { color: var(--accent); background: #e9f1ff; }
.nav-icon { width: 15px; height: 15px; border: 1.5px solid currentColor; border-radius: 3px; flex: 0 0 15px; position: relative; }
.overview-icon::after, .orders-icon::after { content: ""; position: absolute; inset: 4px 2px 3px; border-block: 1px solid currentColor; }
.finance-icon { border-radius: 50%; }
.finance-icon::after { content: "¥"; position: absolute; display: grid; place-items: center; inset: 0; font-size: 9px; line-height: 1; }
.settings-icon { transform: scale(.82) rotate(45deg); }
.connections { border-top: 1px solid var(--line); padding-top: 12px; }
.connections:empty { display: none; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 3px 0; display: flex; align-items: center; justify-content: space-between; gap: 4px; overflow-wrap: anywhere; }
.sidebar-foot strong { font-size: .84rem; }
.sidebar-foot small { display: block; color: var(--muted); font-size: .75rem; }
.main { min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; min-height: 61px; gap: 9px; background: #fff; padding: 10px clamp(14px, 4vw, 38px); border-bottom: 1px solid var(--line); }
.topbar > div:first-child { display: flex; align-items: center; gap: 7px; min-width: 0; }
.topbar select { max-width: min(60vw, 380px); padding: 5px 7px; font-size: .88rem; font-weight: 650; }
.top-caption, .top-date { color: var(--muted); font-size: .84rem; white-space: nowrap; }
#content { display: grid; align-content: start; gap: 14px; width: min(100%, 1500px); margin: 0 auto; padding: clamp(16px, 3.5vw, 36px); outline: none; }
.page-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 2px; }
.page-head p { color: var(--muted); margin-top: 5px; font-size: .9rem; }
.page-head .eyebrow { color: var(--accent); margin-bottom: 5px; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.panel { min-width: 0; border: 1px solid var(--line); background: var(--sheet); border-radius: var(--radius); }
.panel-head { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 11px 15px; }
.panel-head p { color: var(--muted); margin-top: 3px; font-size: .84rem; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.metric { min-height: 84px; padding: 10px 13px; display: grid; gap: 3px; align-content: center; }
.metric dt { color: var(--muted); font-size: .82rem; font-weight: 620; }
.metric dd { font-size: clamp(1rem, 2.1vw, 1.55rem); font-weight: 710; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.metric .accent { color: var(--accent); }
.table-wrap { width: 100%; overflow: auto; border-radius: 0 0 var(--radius) var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { padding: 8px 10px; border-top: 1px solid var(--line); text-align: left; white-space: nowrap; }
th:first-child, td:first-child { padding-left: 14px; }
th:last-child, td:last-child { padding-right: 14px; }
th { color: var(--muted); font-size: .81rem; font-weight: 680; background: #f5f8fc; }
tbody tr:hover { background: #f9fbff; }
td span.muted, td small { display: block; color: var(--muted); font-size: .76rem; }
td .balance { color: var(--accent-deep); font-weight: 700; }
td.number, th.number, .number { font-variant-numeric: tabular-nums; text-align: right; }
.ledger-table th, .ledger-table td { padding-inline: 7px; }
.ledger-table td:first-child, .ledger-table th:first-child { padding-left: 12px; }
.ledger-table .amount-column { min-width: 82px; }
.ledger-table .purpose-column { white-space: normal; min-width: 110px; overflow-wrap: anywhere; }
.ledger-table .balance-column { min-width: 105px; }
.ledger-table .account-column { white-space: normal; min-width: 77px; overflow-wrap: anywhere; }
.ledger-table .time-column { min-width: 74px; }
.thin { color: var(--muted); }
.badge { display: inline-flex; gap: 4px; align-items: center; font-size: .75rem; font-weight: 650; color: #415773; background: #ecf1f9; border-radius: 5px; padding: 3px 7px; white-space: nowrap; }
.badge.ok { color: var(--good); background: var(--good-soft); }
.badge.wait { color: var(--warn); background: var(--warn-soft); }
.badge.bad { color: var(--bad); background: var(--bad-soft); }
.tabs { display: flex; gap: 3px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); padding: 8px 11px; font-weight: 640; font-size: .87rem; }
.tabs button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.filter-row { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; padding: 3px 0 0; }
.filter-row label { gap: 2px; font-size: .77rem; }
.filter-row input, .filter-row select { padding: 5px 6px; min-height: 34px; max-width: 218px; font-size: .83rem; }
.empty { padding: 24px 15px; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }
.empty .button { margin-top: 12px; }
.inline-message { padding: 9px 13px; color: #3a587f; background: #eef4ff; border: 1px solid #dfe9fc; border-radius: 8px; }
.form-error { color: var(--bad); background: var(--bad-soft); border: 1px solid #f6d9dc; border-radius: 7px; padding: 8px 9px; overflow-wrap: anywhere; }
#dialog { width: min(92vw, 570px); padding: 0; max-height: 88dvh; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 70px #0b204032; }
#dialog::backdrop { background: #132b55aa; }
.dialog-head, .dialog-body, .dialog-foot { padding: 14px 17px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); }
.dialog-head p { color: var(--muted); margin-top: 5px; font-size: .84rem; }
.dialog-body { display: grid; gap: 11px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 7px; border-top: 1px solid var(--line); }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.fields .wide { grid-column: 1 / -1; }
.notice { position: fixed; z-index: 30; bottom: 16px; right: 16px; max-width: min(450px, calc(100vw - 32px)); padding: 10px 13px; background: #172a4b; color: #fff; border-radius: 8px; box-shadow: 0 8px 20px #0b204022; }
.order-result { display: grid; gap: 12px; }
.order-issues { padding: 0 14px 12px; color: var(--warn); }
.order-issues p + p { margin-top: 2px; }
.order-export { padding: 0 14px 13px; }
.order-export label { min-width: 130px; }
.issues-ok { margin: 0 14px 12px; color: var(--good); }
.settings-columns { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 12px; }
.account-details { display: grid; gap: 1px; }
@media (max-width: 960px) {
  .workspace { grid-template-columns: 156px minmax(0, 1fr); }
  .sidebar { gap: 18px; padding-inline: 8px; }
  .nav a, .connections a { padding-inline: 7px; }
  #content { padding: 16px; }
}
@media (max-width: 670px) {
  .workspace, .login { display: block; }
  .login-side { gap: 25px; padding: 22px; }
  .login-side .eyebrow, .top-date { display: none; }
  .login-side h1 { font-size: 2rem; }
  .login-rule { margin: 12px 0 8px; }
  .sidebar { position: static; height: auto; display: grid; gap: 7px; padding: 9px 10px 7px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin: 0; }
  .brand-mark { width: 28px; height: 28px; flex-basis: 28px; }
  .brand strong, .brand small { display: inline; }
  .brand small { margin-left: 3px; }
  .nav, .connections { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav a, .connections a { min-height: 34px; padding: 4px 7px; }
  .connections { padding: 3px 0; }
  .sidebar-foot { padding: 3px 1px 0; }
  .sidebar-foot small { display: inline; margin-left: 7px; }
  .topbar { min-height: 46px; padding: 5px 12px; }
  #content { padding: 12px; gap: 10px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { min-height: 64px; }
  .settings-columns { grid-template-columns: 1fr; }
  th, td { padding: 6px 7px; }
}
.platform-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 0 13px 13px; }
.platform-metrics .metric { min-height: 67px; padding-inline: 9px; }
.platform-metrics .metric dd { font-size: clamp(.95rem, 2vw, 1.27rem); overflow-wrap: anywhere; }
@media (max-width: 460px) {
  .platform-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
