*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --sidebar: #f5f6f8;
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted: #666666;
  --input-bg: #f4f5f7;
  --input-border: #e8eaed;
  --btn-code: #9ed0ef;
  --btn-code-hover: #88c4e8;
  --accent: #2ec4b6;
  --submit: #2ec4b6;
  --submit-hover: #26b0a3;
  --nav-blue: #2f6bff;
  --topbar-h: 56px;
  --radius: 6px;
  --font: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 24px;
  height: var(--topbar-h);
  padding: 0 28px 0 20px;
  background: #fff;
  border-bottom: 1px solid #eef0f3;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  text-decoration: none;
  color: var(--nav-blue);
  white-space: nowrap;
}

.topbar-logo {
  display: block;
  width: 28px;
  height: 28px;
}

.topbar-logo svg {
  display: block;
  width: 100%;
  height: 100%;
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.topbar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  min-width: 0;
  gap: 0;
}

.nav-item {
  flex: 1;
  padding: 6px 4px;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  text-align: center;
  text-decoration: none;
  border-radius: 4px;
  transition: color 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}

.nav-item:hover {
  color: #111;
  background: #f5f6f8;
}

.page {
  display: flex;
  min-height: calc(100vh - var(--topbar-h));
  min-height: calc(100dvh - var(--topbar-h));
}

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid #e6e8ec;
  overflow-y: auto;
  overflow-x: hidden;
}

.side-nav {
  padding: 14px 10px 24px;
}

.side-group + .side-group {
  margin-top: 10px;
}

.side-group-title {
  padding: 10px 12px 6px;
  font-size: 12px;
  font-weight: 500;
  color: #8a9099;
  letter-spacing: 0.04em;
}

.side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 12px;
  margin-bottom: 2px;
  border-radius: 6px;
  color: #1a1a1a;
  text-decoration: none;
  font-size: 14px;
  line-height: 1.3;
  transition: background 0.15s ease, color 0.15s ease;
}

.side-item:hover {
  background: #e9ebef;
  color: #000;
}

.side-item.is-active {
  background: #e2e5ea;
  color: #000;
}

.side-icon {
  display: flex;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: #4b5563;
}

.side-item:hover .side-icon,
.side-item.is-active .side-icon {
  color: #111827;
}

.side-icon svg {
  width: 100%;
  height: 100%;
}

.side-text {
  flex: 1;
  min-width: 0;
}

.side-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: #2ec4b6;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.side-arrow {
  flex-shrink: 0;
  color: #9ca3af;
  font-size: 18px;
  line-height: 1;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  background: var(--bg);
}

.panel-toggle {
  display: none;
}

.login-wrap {
  width: 100%;
  max-width: 420px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 48px;
}

.logo {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
}

.logo svg {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-text h1 {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.02em;
  color: #111;
}

.brand-text p {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 400;
  color: #333;
  letter-spacing: 0.01em;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.login-fields {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.login-actions {
  flex-shrink: 0;
}

.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #111;
}

.row {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.input-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px;
  background: var(--input-bg);
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-box--full {
  width: 100%;
}

.input-box:focus-within {
  border-color: #c5e4f5;
  box-shadow: 0 0 0 2px rgba(158, 208, 239, 0.35);
  background: #fff;
}

.icon {
  display: flex;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: #9aa0a6;
}

.icon svg {
  width: 100%;
  height: 100%;
}

.input-box input {
  flex: 1;
  width: 100%;
  min-width: 0;
  height: 44px;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  /* ≥16px：避免 iOS 聚焦时自动放大页面 */
  font-size: 16px;
  color: var(--text);
  transform: translateZ(0);
}

.input-box input::placeholder {
  color: #b0b4ba;
}

.btn-code {
  flex-shrink: 0;
  min-width: 110px;
  padding: 0 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--btn-code);
  color: #1a1a1a;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
  white-space: nowrap;
}

.btn-code:hover:not(:disabled) {
  background: var(--btn-code-hover);
}

.btn-code:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-submit {
  margin-top: 8px;
  width: 100%;
  height: 46px;
  border: none;
  border-radius: var(--radius);
  background: var(--submit);
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-submit:hover {
  background: var(--submit-hover);
}

.btn-submit.is-logging-in,
.btn-submit.is-logging-in:hover {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: not-allowed;
  background: var(--submit);
}

.btn-login-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes btn-spin {
  to {
    transform: rotate(360deg);
  }
}

.msg-mask {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.45);
}

.msg-mask[hidden] {
  display: none;
}

.msg-box {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  animation: msg-in 0.18s ease-out;
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.msg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #ebeef5;
}

.msg-title {
  font-size: 16px;
  font-weight: 600;
  color: #303133;
}

.msg-close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: #909399;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
}

.msg-close:hover {
  color: #606266;
  background: #f5f7fa;
}

.msg-body {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 24px 20px;
}

.msg-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  margin-top: 1px;
}

.msg-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.msg-text {
  font-size: 15px;
  line-height: 1.6;
  color: #606266;
  word-break: break-word;
  white-space: pre-line;
}

.msg-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 18px 16px;
}

.msg-cancel {
  min-width: 72px;
  height: 34px;
  padding: 0 18px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  background: #fff;
  color: #606266;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.msg-cancel:hover {
  color: #409eff;
  border-color: #c6e2ff;
  background: #ecf5ff;
}

.msg-cancel[hidden] {
  display: none;
}

.msg-ok {
  min-width: 72px;
  height: 34px;
  padding: 0 18px;
  border: none;
  border-radius: 4px;
  background: #409eff;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.msg-ok:hover {
  background: #66b1ff;
}

@media (max-width: 1100px) {
  .topbar {
    gap: 16px;
  }

  .nav-item {
    padding: 6px 8px;
    font-size: 13px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 200px;
  }

  .topbar-title {
    font-size: 13px;
  }

  .brand-text h1 {
    font-size: 24px;
  }

  .login-wrap {
    max-width: 360px;
  }
}

@media (max-width: 900px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  body {
    display: flex;
    flex-direction: column;
  }

  .topbar {
    flex-shrink: 0;
    z-index: 100;
    height: auto;
    min-height: var(--topbar-h);
    flex-wrap: nowrap;
    padding: 10px 12px;
    gap: 8px;
    overflow: hidden;
  }

  .topbar-brand {
    flex-shrink: 0;
  }

  .topbar-title {
    font-size: 13px;
  }

  /* 主页 / 商家中心等：左右滑动看其余项 */
  .topbar-nav {
    flex: 1;
    min-width: 0;
    justify-content: flex-start;
    gap: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    touch-action: pan-x;
  }

  .topbar-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    flex: 0 0 auto;
    padding: 6px 10px;
    font-size: 13px;
  }

  .page {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background-color: #0a1628;
    background-image: url("bg-mobile.png");
    background-repeat: no-repeat;
    background-position: center top;
    background-size: cover;
  }

  /* 用户中心带背景图 */
  .sidebar {
    display: block;
    width: 100%;
    flex: 1;
    min-height: 0;
    border-right: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: transparent;
  }

  .side-nav {
    padding: 6px 8px 24px;
  }

  .side-group + .side-group {
    margin-top: 2px;
  }

  .side-group-title {
    padding: 4px 10px 2px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
  }

  .side-item {
    min-height: 32px;
    padding: 5px 10px;
    margin-bottom: 0;
    font-size: 13px;
    color: #f2f6fc;
  }

  .side-item:hover,
  .side-item.is-active {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
  }

  .side-icon {
    width: 15px;
    height: 15px;
    color: rgba(220, 235, 255, 0.85);
  }

  .side-item:hover .side-icon,
  .side-item.is-active .side-icon {
    color: #fff;
  }

  .side-arrow {
    color: rgba(255, 255, 255, 0.45);
  }

  .page:not(.login-collapsed) .side-nav {
    padding-bottom: 12px;
  }

  /* 商户后台系统：不带背景图，白底面板 */
  .main {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 50;
    flex: none;
    width: 100%;
    max-height: none;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 0;
    background: #fff;
    background-image: none;
    border-top: 1px solid #e6e8ec;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.12);
    overflow: hidden;
  }

  .page.login-collapsed .main {
    top: auto !important;
    height: 44px !important;
    max-height: 44px !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
  }

  .panel-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 10px 16px;
    border: none;
    border-bottom: 1px solid #eef0f3;
    background: #f5f6f8;
    color: #1a1a1a;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
  }

  .panel-toggle:active {
    background: #e9ebef;
  }

  .panel-toggle-tri {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid #333;
    transition: transform 0.2s ease;
    transform-origin: 50% 45%;
  }

  .page.login-collapsed .panel-toggle-tri {
    transform: rotate(-90deg);
  }

  .panel-toggle-text {
    letter-spacing: 0.02em;
  }

  .login-wrap {
    max-width: none;
    flex: 1 1 auto;
    min-height: 0;
    padding: 8px 16px 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
  }

  .page.login-collapsed .login-wrap {
    display: none;
  }

  .login-form {
    flex: 1 1 auto;
    min-height: 0;
    gap: 8px;
    display: flex;
    flex-direction: column;
  }

  .login-fields {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
    padding-bottom: 4px;
  }

  /* 登录按钮固定在表单底部，二级密码展开时也不会被裁掉 */
  .login-actions {
    flex-shrink: 0;
    padding-top: 6px;
    background: #fff;
  }

  .page.two-step-open .brand-text p {
    display: none;
  }

  .page.two-step-open .brand {
    margin-bottom: 4px;
  }

  .login-bottom-blank {
    display: none;
  }

  .page.login-collapsed .login-bottom-blank {
    display: none;
  }

  /* 列表底部留白，避免最后几项被登录面板挡住无法滚到 */
  .page:not(.login-collapsed) .sidebar .side-nav::after {
    content: "";
    display: block;
    height: var(--login-panel-h, 50vh);
  }

  .page.login-collapsed .sidebar .side-nav::after {
    content: "";
    display: block;
    height: var(--login-panel-h, 56px);
  }

  .brand {
    margin-bottom: 10px;
    gap: 10px;
  }

  .brand .logo {
    width: 40px;
    height: 40px;
  }

  .brand-text h1 {
    font-size: 18px;
    color: var(--text);
  }

  .brand-text p {
    font-size: 12px;
    color: var(--muted);
  }

  .field {
    margin-bottom: 0;
  }

  .field label {
    color: var(--text);
    margin-bottom: 4px;
  }

  .input-box,
  .input-box--full {
    background: var(--input-bg);
  }

  .row {
    flex-direction: column;
    gap: 8px;
  }

  .btn-code {
    height: 40px;
    width: 100%;
  }

  .btn-submit {
    height: 42px;
    margin-top: 0;
  }

  /* 手机端输入框保持 16px，只弹键盘不放大 */
  .input-box input {
    font-size: 16px;
    height: 44px;
  }
}
