* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

.app {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 14px;
}

.sidebar-logo img {
  width: 50px;
  height: 50px;
  margin-left: -9px;
}

.sidebar-logo .logo-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.sidebar-logo .logo-sub {
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 13.5px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item svg {
  width: 17px;
  height: 17px;
  stroke-width: 1.8;
}

.nav-item:hover {
  background: var(--bg-soft);
  color: var(--text);
}

.nav-item.active {
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 600;
}

.sidebar-quota {
  margin: 12px;
  padding: 14px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.quota-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
}

.quota-head svg {
  width: 14px;
  height: 14px;
  color: var(--orange);
}

.quota-head em {
  margin-left: auto;
  font-style: normal;
  font-size: 12px;
  color: var(--blue);
}

.quota-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--bg-soft);
  margin: 10px 0 8px;
  overflow: hidden;
}

.quota-bar i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--blue), var(--violet));
}

.quota-text {
  font-size: 11px;
  color: var(--text-3);
}

.quota-upgrade {
  margin-top: 10px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-soft);
  border: 1px solid rgba(46, 107, 255, 0.16);
  border-radius: var(--r-md);
  padding: 7px 0;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quota-upgrade:hover {
  background: var(--blue);
  color: #fff;
}

.quota-upgrade svg {
  width: 13px;
  height: 13px;
}

.sidebar-brand {
  margin: 12px;
  padding: 16px;
  border-radius: var(--r-lg);
  background: var(--grad-ai-soft);
  border: 1px solid rgba(124, 92, 255, 0.14);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.sidebar-brand img {
  width: 96px;
  height: 96px;
  object-fit: contain;
  animation: orb-float 7s ease-in-out infinite;
}

.sidebar-brand .brand-title {
  font-size: 13px;
  font-weight: 700;
  margin-top: 6px;
  background: var(--grad-ai);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-brand .brand-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}

@keyframes orb-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-7px);
  }
}

/* ---------- Main column ---------- */

.app-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
  background:
    linear-gradient(to bottom, rgba(245, 247, 252, 0) 26%, rgba(245, 247, 252, 0.85) 58%, var(--bg) 74%),
    url("../img/bg-hero.webp") top center / 100% auto no-repeat;
}

body:not([data-page="home"]) .app-main {
  background:
    linear-gradient(to bottom, rgba(245, 247, 252, 0.72) 0%, rgba(245, 247, 252, 0.92) 34%, var(--bg) 52%),
    url("../img/bg-hero.webp") top center / 100% auto no-repeat;
}

.topbar {
  height: var(--topbar-h);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-search {
  flex: 1;
  max-width: 560px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 8px 14px;
  color: var(--text-3);
  cursor: text;
  transition: border 0.15s ease, background 0.15s ease;
}

.topbar-search:focus-within {
  background: var(--surface);
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(46, 107, 255, 0.12);
}

.topbar-search svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.topbar-search input {
  border: none;
  outline: none;
  background: transparent;
  flex: 1;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
}

.topbar-search kbd {
  font-family: var(--font);
  font-size: 11px;
  color: var(--text-3);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 1px 7px;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease;
}

.icon-btn:hover {
  background: var(--bg-soft);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

.icon-btn .dot {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  border: 1.5px solid var(--surface);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 12px;
  margin-left: 6px;
  border-left: 1px solid var(--border);
  cursor: pointer;
}

.topbar-user img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--blue-soft);
}

.topbar-user .user-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.topbar-user .user-role {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.3;
}

/* ---------- Page root ---------- */

.page-root {
  padding: 24px 28px 48px;
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.page-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.page-rail {
  width: var(--rail-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: calc(var(--topbar-h) + 24px);
}

@media (max-width: 1280px) {
  :root {
    --sidebar-w: 192px;
  }
}

@media (max-width: 1279px) {
  .page-rail {
    display: none;
  }
}
