:root {
  color: #18202a;
  background: #eef1f4;
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
  --ink: #18202a;
  --muted: #657282;
  --line: #d9dee5;
  --surface: #ffffff;
  --surface-soft: #f6f8fa;
  --blue: #1267d6;
  --blue-dark: #0b4d9c;
  --green: #21825b;
  --amber: #a86600;
  --red: #b4232f;
  --sidebar: #202833;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { min-width: 320px; }
button, input, select { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(260px, 38%) 1fr;
  background: var(--surface);
}

.auth-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  overflow: hidden;
  color: #fff;
  background: #172331;
}

.auth-brand::after {
  content: "";
  position: absolute;
  inset: auto -80px -160px 20%;
  height: 360px;
  background: linear-gradient(135deg, rgba(18,103,214,.05), rgba(71,189,228,.2));
  transform: skewY(-11deg);
}

.brand-lockup { display: flex; align-items: center; gap: 14px; position: relative; z-index: 1; }
.brand-lockup img { width: 52px; height: 52px; object-fit: contain; background: #fff; }
.brand-lockup strong { display: block; font-size: 21px; font-weight: 700; }
.brand-lockup span { display: block; color: #afbdca; font-size: 13px; margin-top: 3px; }
.auth-brand-copy { position: relative; z-index: 1; max-width: 440px; padding-bottom: 5vh; }
.auth-brand-copy h1 { margin: 0 0 16px; font-size: 36px; line-height: 1.2; font-weight: 700; }
.auth-brand-copy p { margin: 0; color: #cbd5df; font-size: 16px; line-height: 1.8; }
.auth-brand footer { position: relative; z-index: 1; color: #8091a3; font-size: 12px; }

.auth-main { display: grid; place-items: center; padding: 32px; }
.auth-form { width: min(420px, 100%); }
.auth-form h2 { margin: 0 0 8px; font-size: 27px; }
.auth-form > p { margin: 0 0 30px; color: var(--muted); }
.field { display: grid; gap: 8px; margin-bottom: 18px; }
.field label { font-weight: 600; font-size: 14px; }
.field input, .field select {
  width: 100%; height: 44px; padding: 0 12px; border: 1px solid #cbd2da;
  border-radius: 5px; background: #fff; color: var(--ink); outline: none;
}
.field input:focus, .field select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(18,103,214,.12); }
.primary-button, .secondary-button, .danger-button {
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
  min-height: 40px; border-radius: 5px; border: 1px solid transparent;
  padding: 0 17px; cursor: pointer; font-weight: 600;
}
.primary-button { color: #fff; background: var(--blue); }
.primary-button:hover { background: var(--blue-dark); }
.secondary-button { color: var(--ink); border-color: #cbd2da; background: #fff; }
.secondary-button:hover { background: #f3f5f7; }
.danger-button { color: #fff; background: var(--red); }
button:disabled { cursor: not-allowed; opacity: .55; }
.full-width { width: 100%; }
.auth-actions { display: flex; justify-content: space-between; margin-top: 19px; font-size: 14px; }
.auth-actions a { color: var(--blue); text-decoration: none; }
.auth-error { min-height: 24px; margin: 12px 0; color: var(--red); font-size: 14px; }

.handoff-state { text-align: center; width: min(460px, 100%); }
.handoff-state img { width: 76px; height: 76px; object-fit: contain; }
.handoff-state h1 { font-size: 23px; margin: 20px 0 8px; }
.handoff-state p { color: var(--muted); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 14px; color: #dbe3eb; background: var(--sidebar); }
.sidebar .brand-lockup { padding: 0 8px 23px; border-bottom: 1px solid #384351; }
.sidebar .brand-lockup img { width: 38px; height: 38px; }
.sidebar .brand-lockup strong { font-size: 16px; }
.sidebar-nav { display: grid; gap: 5px; margin-top: 22px; }
.nav-link {
  display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 0 12px;
  border-radius: 5px; color: #b9c6d3; text-decoration: none; font-weight: 600;
}
.nav-link:hover { color: #fff; background: #2b3542; }
.nav-link.active { color: #fff; background: var(--blue); }
.nav-icon { width: 20px; text-align: center; font-size: 17px; }
.sidebar-foot { position: absolute; left: 14px; right: 14px; bottom: 18px; }
.sidebar-foot button { width: 100%; color: #dbe3eb; border-color: #4b5867; background: transparent; }

.workspace { min-width: 0; }
.topbar {
  height: 64px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.topbar h1 { margin: 0; font-size: 19px; }
.account-chip { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; background: var(--green); font-weight: 700; }
.content { max-width: 1440px; padding: 25px 28px 50px; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 21px; }
.page-heading h2 { margin: 0 0 5px; font-size: 23px; }
.page-heading p { margin: 0; color: var(--muted); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); border: 1px solid var(--line); background: var(--surface); }
.metric { min-height: 112px; padding: 20px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { display: block; color: var(--muted); font-size: 13px; }
.metric strong { display: block; margin-top: 9px; font-size: 28px; line-height: 1.2; }
.metric small { display: block; color: var(--green); margin-top: 5px; }

.section { margin-top: 22px; border-top: 1px solid var(--line); background: var(--surface); }
.section-head { display: flex; align-items: center; justify-content: space-between; min-height: 58px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.section-head h3 { margin: 0; font-size: 16px; }
.section-body { padding: 18px; }
.split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr); gap: 22px; }
.status-line { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.status-dot.off { background: var(--red); }
.notice { padding: 13px 15px; border-left: 3px solid var(--amber); color: #694716; background: #fff8e8; }
.empty { padding: 36px 15px; color: var(--muted); text-align: center; }

.data-table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { padding: 10px 12px; color: var(--muted); background: var(--surface-soft); text-align: left; white-space: nowrap; font-weight: 600; }
.data-table td { padding: 12px; border-top: 1px solid var(--line); white-space: nowrap; }
.data-table td.wrap { white-space: normal; min-width: 180px; }
.table-action { padding: 0; border: 0; color: var(--blue); background: transparent; cursor: pointer; font-weight: 600; }
.table-action:hover { color: var(--blue-dark); text-decoration: underline; }
.tag { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 4px; color: var(--blue-dark); background: #e9f2ff; font-size: 12px; font-weight: 600; }
.tag.green { color: #176341; background: #e5f5ec; }
.tag.gray { color: #596675; background: #edf0f3; }
.tag.red { color: #92202a; background: #fdebee; }

.purchase-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.purchase-form .field { margin: 0; }
.purchase-summary { margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--line); }
.price { font-size: 30px; font-weight: 700; }
.price small { color: var(--muted); font-size: 13px; font-weight: 400; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.account-details { display: grid; grid-template-columns: 150px 1fr; margin: 0; }
.account-details dt, .account-details dd { margin: 0; padding: 12px 0; border-bottom: 1px solid var(--line); }
.account-details dt { color: var(--muted); }
.password-form { width: min(520px, 100%); }

.payment-dialog { width: min(440px, calc(100% - 32px)); padding: 30px; border: 0; border-radius: 6px; box-shadow: 0 18px 60px rgba(20,30,40,.25); }
.payment-dialog::backdrop { background: rgba(15,22,31,.55); }
.dialog-close { position: absolute; right: 12px; top: 10px; }
.icon-button { width: 34px; height: 34px; border: 0; background: transparent; cursor: pointer; font-size: 25px; }
.payment-content { text-align: center; }
.payment-content h3 { margin: 0 0 5px; font-size: 20px; }
.payment-content p { margin: 0; color: var(--muted); }
.payment-content img { display: block; width: min(310px, 100%); aspect-ratio: 1; object-fit: contain; margin: 20px auto 10px; }
.payment-state { margin-top: 13px; color: var(--green); font-weight: 600; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 360px; padding: 12px 16px; border-radius: 5px; color: #fff; background: #26313d; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.loading { min-height: 50vh; display: grid; place-items: center; color: var(--muted); }

@media (max-width: 980px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { min-height: 230px; padding: 26px; }
  .auth-brand-copy { padding: 32px 0 0; }
  .auth-brand-copy h1 { font-size: 28px; }
  .auth-brand footer { display: none; }
  .auth-main { padding: 30px 22px 48px; place-items: start center; }
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 10; top: auto; bottom: 0; width: 100%; height: 64px; padding: 6px 8px; }
  .sidebar .brand-lockup, .sidebar-foot { display: none; }
  .sidebar-nav { grid-template-columns: repeat(5, 1fr); gap: 2px; margin: 0; }
  .nav-link { min-height: 52px; padding: 4px; flex-direction: column; justify-content: center; gap: 1px; font-size: 11px; }
  .nav-icon { font-size: 16px; }
  .topbar { height: 58px; padding: 0 16px; }
  .account-chip span:not(.avatar) { display: none; }
  .content { padding: 18px 14px 90px; }
  .page-heading { display: block; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 96px; padding: 15px; }
  .metric strong { font-size: 23px; }
  .purchase-form { grid-template-columns: 1fr; }
  .account-details { grid-template-columns: 110px 1fr; }
}
