:root {
  color-scheme: light;
  --ink: #30364c;
  --text: #333333;
  --muted: #747b83;
  --line: #e3e5e9;
  --surface: #f3f6fa;
  --panel: #ffffff;
  --blue: #033a90;
  --blue-deep: #00398f;
  --blue-bright: #21ade5;
  --green: #9cc813;
  --yellow: #fdd10b;
  --gold: #c8a54a;
  --danger: #b42318;
  --danger-bg: #fff3f1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #ffffff;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body.auth-booting {
  background: #ffffff;
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.login-shell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(3, 28, 68, 0.74), rgba(3, 28, 68, 0.36)),
    url("/login-cover.jpg") center / cover no-repeat;
}

.login-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 18, 46, 0.16);
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue-bright);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.login-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: min(420px, 100%);
  min-height: auto;
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 18, 46, 0.28);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

.login-logo {
  display: block;
  width: 210px;
  max-width: 78%;
  height: auto;
  margin: 0 auto 30px;
}

.login-heading {
  margin-bottom: 22px;
  text-align: center;
}

.login-heading h2 {
  margin-bottom: 10px;
  font-size: 24px;
}

.login-heading p {
  color: var(--muted);
  line-height: 1.7;
}

.login-methods {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  max-width: 520px;
}

.login-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 116px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.primary-login-card {
  border-color: #c7d7ef;
}

.login-card:hover {
  border-color: #8da6cc;
  box-shadow: 0 16px 36px rgba(0, 57, 143, 0.12);
  transform: translateY(-2px);
}

.login-card:disabled {
  cursor: wait;
  opacity: 0.68;
}

.login-card strong {
  display: block;
  margin-bottom: 12px;
  font-size: 19px;
}

.login-card span:last-child {
  display: block;
  color: var(--muted);
  line-height: 1.7;
}

.error-card {
  max-width: 720px;
  margin-bottom: 18px;
  padding: 16px 18px;
  border: 1px solid #f0b4ad;
  border-left: 4px solid var(--danger);
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger);
}

.error-card strong {
  display: block;
  margin-bottom: 6px;
}

.error-card p {
  margin-bottom: 0;
  color: #7a271a;
  line-height: 1.6;
}

.debug-box {
  max-width: 720px;
  margin: 18px 0 0;
  padding: 12px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.app-layout {
  position: relative;
  display: grid;
  grid-template-columns: 212px minmax(0, 1fr);
  min-height: 100vh;
  isolation: isolate;
}

.watermark-layer {
  position: fixed;
  inset: -80px;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  grid-auto-rows: 168px;
  gap: 36px 72px;
  align-content: start;
  overflow: hidden;
  pointer-events: none;
  transform: rotate(-24deg);
  transform-origin: center;
}

.watermark-layer span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 320px;
  height: 168px;
  color: rgba(48, 54, 76, 0.07);
  font-size: 15px;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0;
  background: #f8f8f8;
  color: var(--text);
}

.side-brand {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 96px;
  padding: 20px 18px;
  border-bottom: 1px solid #dcdcdc;
  background: #f8f8f8;
}

.app-icon {
  width: 34px;
  height: 34px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 6px 16px rgba(0, 57, 143, 0.12);
}

.side-brand strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: #25282d;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-nav {
  display: grid;
  gap: 0;
}

.nav-group {
  display: grid;
  gap: 0;
  border-bottom: 1px solid #e2e2e2;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 48px;
  padding: 0 16px 0 20px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #111;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  text-align: left;
  transition: background 120ms ease, color 120ms ease;
}

.nav-label {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  object-fit: contain;
  object-position: center;
}

.nav-item:hover,
.nav-item.active {
  background: #ffffff;
  color: #111;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--blue);
}

.nav-item::after {
  content: "›";
  display: inline-block;
  color: #2f3338;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  transition: transform 120ms ease;
}

.nav-item.active::after {
  color: #2f3338;
}

.nav-item[aria-expanded="true"]::after {
  transform: rotate(90deg);
}

.sub-nav-list {
  display: grid;
  gap: 12px;
  padding: 10px 10px 12px 18px;
  background: #f8f8f8;
}

.nav-group.collapsed .sub-nav-list {
  display: none;
}

.sub-nav-item {
  width: 100%;
  min-height: 36px;
  padding: 0 12px 0 18px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #5f6670;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.2;
  text-align: left;
  transition: background 120ms ease, color 120ms ease;
}

.sub-nav-item:hover,
.sub-nav-item.active {
  background: #ffffff;
  color: #111;
  font-weight: 700;
}

.sidebar-bottom {
  position: relative;
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid #dcdcdc;
}

.user-popover-anchor {
  position: relative;
}

.user-info-wrap {
  position: relative;
  min-width: 0;
}

.user-info-wrap::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 10px;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 58px;
  padding: 8px;
  border: 1px solid #d8d8d8;
  border-radius: 8px;
  background: #ffffff;
}

.user-profile-button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 42px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
  background: #edf2fb;
}

.user-profile-button strong,
.user-profile-button small {
  display: block;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-profile-button strong {
  font-size: 14px;
  line-height: 1.25;
}

.user-profile-button small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.user-popover {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 10;
  width: 280px;
  max-height: min(360px, calc(100vh - 148px));
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 16px 34px rgba(48, 54, 76, 0.14);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.user-popover::-webkit-scrollbar {
  width: 6px;
}

.user-popover::-webkit-scrollbar-track {
  background: transparent;
}

.user-popover::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #c7d0dc;
}

.user-menu {
  position: relative;
  display: flex;
  align-self: stretch;
  align-items: center;
  justify-content: center;
}

.user-menu::before {
  content: "";
  position: absolute;
  left: 100%;
  top: 50%;
  width: 12px;
  height: 48px;
  transform: translateY(-50%);
}

.more-button {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 28px;
  height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.more-button span {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #7b828c;
}

.logout-menu {
  position: absolute;
  left: calc(100% + 8px);
  bottom: auto;
  top: 50%;
  z-index: 12;
  min-width: max-content;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(48, 54, 76, 0.16);
  opacity: 0;
  pointer-events: none;
  transform: translate(-6px, -50%);
  transition: opacity 140ms ease, transform 140ms ease;
}

.user-menu:hover .logout-menu,
.user-menu:focus-within .logout-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translate(0, -50%);
}

.logout-button {
  width: auto;
  min-height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
}

.logout-button:hover {
  background: #f2f6fc;
  color: var(--blue);
}

.more-button:hover {
  background: #f2f6fc;
}

.user-info-wrap:hover .user-popover,
.user-info-wrap:focus-within .user-popover {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.user-popover dl {
  display: grid;
  gap: 12px;
  margin: 0;
}

.user-popover div {
  display: grid;
  gap: 4px;
}

.user-popover dt {
  color: var(--muted);
  font-size: 12px;
}

.user-popover dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 13px;
}

.content-area {
  min-width: 0;
  padding: 24px 28px;
  background: #ffffff;
}

.content-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.content-topbar h1 {
  margin-bottom: 0;
  color: #25282d;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.35;
}

.feature-panel {
  display: grid;
  place-items: center;
  min-height: 320px;
  text-align: center;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.feature-panel h2 {
  margin-bottom: 8px;
  color: #25282d;
  font-size: 18px;
  font-weight: 700;
}

.feature-panel p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

@media (max-width: 960px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .login-panel {
    padding: 28px 22px;
  }

  .sidebar {
    gap: 18px;
  }

  .user-popover {
    left: auto;
    right: 0;
  }
}

@media (max-width: 720px) {
  .login-methods {
    grid-template-columns: 1fr;
  }

  .content-area {
    padding: 20px 14px;
  }

  .content-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .user-popover {
    width: min(318px, calc(100vw - 36px));
  }
}
