:root {
  color-scheme: light;
  --ink: #15233a;
  --muted: #6f7d91;
  --line: #e2e8f0;
  --paper: #ffffff;
  --canvas: #f5f7fb;
  --navy: #17294a;
  --blue: #2764e7;
  --blue-dark: #1e4fc0;
  --blue-soft: #eaf1ff;
  --green: #14805e;
  --green-soft: #e4f6ef;
  --amber: #a4660a;
  --amber-soft: #fff4d8;
  --orange: #bd4f15;
  --orange-soft: #ffede2;
  --red: #b93843;
  --red-soft: #fdebed;
  --purple: #7157bd;
  --purple-soft: #f0ebff;
  --shadow: 0 12px 34px rgba(27, 45, 77, .07);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); }
button, .button, input, select { font: inherit; }
button, .button {
  min-height: 38px; border: 1px solid #d7dfeb; border-radius: 9px; padding: .55rem .85rem;
  background: var(--paper); color: #2b3a53; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem; font-weight: 600;
}
button:hover, .button:hover { border-color: #9eb3d2; background: #f9fbff; }
button:focus-visible, .button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(39, 100, 231, .18); outline-offset: 1px; }
.primary { color: #fff; background: var(--blue); border-color: var(--blue); }
.primary:hover { color: #fff; background: var(--blue-dark); border-color: var(--blue-dark); }
.secondary { color: #dce8ff; background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .16); }
.secondary:hover { color: #fff; background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .24); }
.ghost { border-color: transparent; background: transparent; }
.danger { color: var(--red); }
.full { width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 .42rem; color: var(--blue); font-size: .7rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .4rem; font-size: clamp(1.55rem, 2.4vw, 2rem); letter-spacing: -.025em; }
h2 { margin-bottom: .3rem; font-size: 1.14rem; }
h3 { margin-bottom: .25rem; font-size: 1.02rem; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem; background: radial-gradient(circle at 20% 10%, #e1ebff, transparent 33%), var(--canvas); }
.auth-card { width: min(430px, 100%); padding: 2rem; border: 1px solid var(--line); border-radius: 20px; background: var(--paper); box-shadow: var(--shadow); }
.auth-card.wide { width: min(620px, 100%); }
.brand-mark { width: 42px; height: 42px; margin-bottom: 1rem; border-radius: 12px; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, #3b7af0, #164cb7); font-weight: 800; box-shadow: 0 8px 20px rgba(39, 100, 231, .24); }
label { display: grid; gap: .4rem; margin: .9rem 0; color: #34445d; font-weight: 650; }
label small { color: var(--muted); font-size: .75rem; line-height: 1.45; font-weight: 400; }
input, select { width: 100%; min-height: 42px; border: 1px solid #cfd8e5; border-radius: 9px; padding: .65rem .75rem; color: var(--ink); background: #fff; }
input[readonly] { color: var(--muted); background: #f3f6fa; }
form > .primary { width: 100%; margin-top: .45rem; }
.link-button { padding-left: 0; border: 0; color: var(--blue); background: transparent; }
.qr { display: block; width: 256px; max-width: 100%; margin: 1.1rem auto; border: 1px solid var(--line); border-radius: 14px; }
.warning { padding: .8rem 1rem; border: 1px solid #f2d798; border-radius: 10px; color: #744a0a; background: var(--amber-soft); }
pre { padding: 1rem; border-radius: 10px; overflow: auto; color: #dfe9ff; background: #15233b; line-height: 1.7; }
.button-row { display: flex; justify-content: flex-end; gap: .65rem; flex-wrap: wrap; }

.app-layout { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 1.25rem 1rem; display: flex; flex-direction: column; color: #e4ecfb; background: var(--navy); }
.brand { display: flex; align-items: center; gap: .75rem; padding: .25rem .35rem 1.5rem; }
.brand .brand-mark { flex: 0 0 auto; width: 38px; height: 38px; margin: 0; border-radius: 10px; }
.brand strong, .brand small { display: block; }
.brand small { margin-top: .15rem; color: #91a2bd; font-size: .72rem; }
.main-nav { display: grid; gap: .25rem; }
.nav-item { width: 100%; justify-content: space-between; border-color: transparent; color: #aebbd0; background: transparent; font-weight: 650; }
.nav-item:hover { color: #fff; border-color: transparent; background: rgba(255, 255, 255, .06); }
.nav-item.active { color: #fff; border-color: rgba(255, 255, 255, .08); background: rgba(255, 255, 255, .11); }
.nav-item b { min-width: 1.55rem; padding: .12rem .4rem; border-radius: 999px; color: #bcd0f4; background: rgba(255, 255, 255, .08); font-size: .7rem; text-align: center; }
.sidebar-foot { margin-top: auto; display: grid; gap: .6rem; }
.sidebar-foot .ghost { color: #9eacc1; }
.sidebar-foot .ghost:hover { color: #fff; background: rgba(255, 255, 255, .05); }
.scope-note { color: #8293ae; font-size: .68rem; text-align: center; }

.workspace { width: auto; min-width: 0; max-width: 1640px; padding: 1.6rem 2rem 4rem; overflow: hidden; }
.topbar, .section-head, .dialog-head, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.topbar { margin-bottom: 1.35rem; }
.topbar h1 { margin: 0; }
.top-actions, .toolbar { display: flex; align-items: center; gap: .55rem; }
.toolbar.wrap { flex-wrap: wrap; justify-content: flex-end; }
.toolbar select { width: auto; min-width: 130px; }
.status-badge, .state-badge { display: inline-flex; align-items: center; gap: .38rem; width: max-content; padding: .3rem .62rem; border-radius: 999px; color: #516077; background: #edf1f6; font-size: .72rem; font-weight: 750; white-space: nowrap; }
.status-badge i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-badge.good, .state-badge.good { color: var(--green); background: var(--green-soft); }
.state-badge.wait { color: var(--blue); background: var(--blue-soft); }
.state-badge.rate { color: var(--amber); background: var(--amber-soft); }
.state-badge.limit { color: var(--orange); background: var(--orange-soft); }
.state-badge.danger { color: var(--red); background: var(--red-soft); }
.state-badge.archived { color: #68758a; background: #eef1f5; }
.state-badge.confirm { color: var(--purple); background: var(--purple-soft); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.notice { margin-bottom: 1rem; padding: .85rem 1rem; border: 1px solid #f1d38e; border-radius: 11px; color: #774c09; background: var(--amber-soft); }
.notice.danger { border-color: #f2bec4; color: #862c35; background: var(--red-soft); }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem; margin-bottom: 1rem; }
.metric-card, .panel, .audit-summary article { border: 1px solid var(--line); background: var(--paper); box-shadow: var(--shadow); }
.metric-card { position: relative; min-height: 132px; padding: 1.05rem 1.15rem; border-radius: 14px; overflow: hidden; }
.metric-card.accent::after { content: ""; position: absolute; right: -25px; bottom: -35px; width: 110px; height: 110px; border-radius: 50%; background: var(--blue-soft); }
.metric-card span, .audit-summary span { color: var(--muted); font-size: .78rem; font-weight: 600; }
.metric-card strong, .audit-summary strong { display: block; margin: .5rem 0 .35rem; font-size: 1.62rem; letter-spacing: -.025em; }
.metric-card small { color: #8591a3; font-size: .72rem; }
.panel { margin-bottom: 1rem; padding: 1.15rem; border-radius: 14px; }
.section-head p { margin: 0; color: var(--muted); font-size: .8rem; }
.overview-list { margin-top: 1rem; display: grid; gap: .65rem; }
.overview-row { display: grid; grid-template-columns: minmax(170px, 1.4fr) minmax(150px, 1.2fr) minmax(160px, 1.3fr) minmax(130px, .8fr) auto; align-items: center; gap: .9rem; padding: .85rem .9rem; border: 1px solid var(--line); border-radius: 11px; }
.overview-row .identity strong, .overview-row .identity small { display: block; }
.overview-row small, .detail-muted { color: var(--muted); font-size: .72rem; }
.progress-line { display: flex; justify-content: space-between; gap: .7rem; margin-bottom: .35rem; font-size: .76rem; }
.progress-track { height: 6px; border-radius: 999px; overflow: hidden; background: #e9eef5; }
.progress-track i { display: block; height: 100%; border-radius: inherit; background: var(--blue); }

.account-create-form { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.4fr) auto; gap: .8rem; align-items: end; margin-top: 1rem; padding-top: .4rem; border-top: 1px solid var(--line); }
.account-create-form label { margin-bottom: 0; }
.account-create-form > .primary { width: auto; height: 42px; margin: 0 0 1.7rem; }
.account-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.account-card { padding: 1.1rem; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); box-shadow: var(--shadow); }
.account-card.archived { opacity: .72; background: #f7f8fa; }
.account-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.account-title code { color: var(--muted); font-size: .73rem; }
.account-status-copy { margin: .7rem 0; min-height: 2.2rem; color: #5f6d81; font-size: .78rem; line-height: 1.45; }
.account-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; margin: .8rem 0; }
.fact { min-width: 0; padding: .68rem; border-radius: 9px; background: #f7f9fc; }
.fact span, .fact strong { display: block; }
.fact span { margin-bottom: .25rem; color: var(--muted); font-size: .68rem; }
.fact strong { overflow-wrap: anywhere; font-size: .8rem; }
.card-actions { display: flex; gap: .45rem; flex-wrap: wrap; padding-top: .75rem; border-top: 1px solid var(--line); }
.card-actions button { min-height: 34px; padding: .42rem .68rem; font-size: .74rem; }

.table-wrap { margin-top: 1rem; overflow: auto; }
table { width: 100%; min-width: 780px; border-collapse: collapse; }
th, td { padding: .75rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: .69rem; letter-spacing: .045em; text-transform: uppercase; }
td { font-size: .81rem; }
td code { color: #45546a; }
.address-cell { display: flex; align-items: center; gap: .45rem; }
.copy-one { min-height: 28px; padding: .25rem .45rem; border: 0; color: var(--blue); background: transparent; font-size: .68rem; }
.empty { padding: 2rem; color: var(--muted); text-align: center; }
.audit-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: .85rem; margin-bottom: 1rem; }
.audit-summary article { padding: 1rem; border-radius: 13px; }
.audit-summary strong { font-size: 1.2rem; }

.settings-dialog { width: min(610px, calc(100% - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 0; border-radius: 16px; color: var(--ink); box-shadow: 0 24px 80px rgba(13, 27, 53, .24); }
.settings-dialog::backdrop { background: rgba(17, 29, 51, .48); backdrop-filter: blur(2px); }
.settings-dialog form { padding: 1.3rem; }
.settings-dialog form > .primary { width: auto; margin: 0; }
.dialog-head { margin-bottom: .8rem; }
.dialog-head h2 { margin: 0; }
.icon-button { min-width: 38px; padding: 0; font-size: 1.4rem; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.check-row { grid-template-columns: auto 1fr; align-items: start; padding: .75rem; border: 1px solid var(--line); border-radius: 10px; background: #f8faff; }
.check-row input { width: 18px; min-height: 18px; margin-top: .1rem; }
.dialog-actions { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.spacer { flex: 1; }

.toast { position: fixed; z-index: 100; right: 1rem; bottom: 1rem; max-width: min(440px, calc(100% - 2rem)); padding: .8rem 1rem; border-radius: 10px; color: #fff; background: #183b31; box-shadow: 0 16px 44px rgba(0, 0, 0, .18); transform: translateY(160%); transition: transform .2s ease; }
.toast.visible { transform: translateY(0); }
.toast.bad { background: #8e3039; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .account-grid { grid-template-columns: 1fr; }
  .overview-row { grid-template-columns: 1.3fr 1fr 1fr auto; }
  .overview-row .overview-forward { display: none; }
}

@media (max-width: 820px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; width: 100%; height: auto; padding: .8rem; }
  .brand { padding-bottom: .75rem; }
  .main-nav { grid-template-columns: repeat(4, 1fr); }
  .nav-item { justify-content: center; }
  .nav-item b { display: none; }
  .sidebar-foot { margin-top: .7rem; grid-template-columns: 1fr 1fr; }
  .scope-note { display: none; }
  .workspace { padding: 1rem 1rem 3rem; }
  .topbar, .section-head { align-items: flex-start; flex-direction: column; }
  .toolbar.wrap { justify-content: flex-start; }
  .account-create-form { grid-template-columns: 1fr 1fr; }
  .account-create-form > .primary { grid-column: 1 / -1; margin-bottom: 0; }
  .overview-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .auth-shell { padding: .75rem; }
  .auth-card { padding: 1.25rem; }
  .main-nav { grid-template-columns: repeat(2, 1fr); }
  .metric-grid, .audit-summary, .account-create-form, .two-columns, .account-facts { grid-template-columns: 1fr; }
  .overview-row { grid-template-columns: 1fr; }
  .top-actions, .toolbar { width: 100%; flex-wrap: wrap; }
  .toolbar > *, .top-actions > * { flex: 1; }
  .dialog-actions { flex-wrap: wrap; }
  .dialog-actions .spacer { display: none; }
}
