:root {
  --bg: #faf8ff;
  --bg2: #f0ecf5;
  --panel: #ffffff;
  --stroke: rgba(124,58,237,0.12);
  --stroke2: rgba(124,58,237,0.18);
  --text: #0f0d1a;
  --muted: rgba(15,13,26,0.55);
  --good: #22c55e;
  --bad: #ed1c00;
  --accent: #7C3AED;
  --accent-hover: #6D28D9;
  --accent-light: #A78BFA;
  --accent2: #ff6b2c;
  --gradient: linear-gradient(135deg, #ff6b2c, #7C3AED);
  --shadow-card: 0 2px 12px rgba(124,58,237,0.06);
  --shadow-hover: 0 6px 24px rgba(124,58,237,0.12);
  --glass-bg: rgba(255,255,255,0.72);
  --glass-blur: blur(20px);
}

html.dark {
  --bg: #0f0d1a;
  --bg2: #1e1b2e;
  --panel: #1e1b2e;
  --stroke: rgba(255,255,255,0.08);
  --stroke2: rgba(255,255,255,0.12);
  --text: #faf8ff;
  --muted: rgba(250,248,255,0.55);
  --shadow-card: 0 2px 12px rgba(0,0,0,0.25);
  --shadow-hover: 0 6px 24px rgba(124,58,237,0.18);
  --glass-bg: rgba(30,27,46,0.72);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 6px; opacity: 0.5; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-hover); }
* { scrollbar-width: thin; scrollbar-color: var(--accent) transparent; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 'Manrope', ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
}

.app {
  height: 100%;
  display: grid;
  grid-template-columns: 270px 1fr;
  gap: 14px;
  padding: 14px;
}

.sidebar {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--stroke);
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  width: 270px;
  transition: width 0.18s ease, background 0.3s;
  box-shadow: var(--shadow-card);
}

.sidebar.collapsed { width: 62px; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .side-bottom,
.sidebar.collapsed .nav-item span:last-child { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; }

.side-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--stroke);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 2px solid transparent;
  background: var(--gradient) border-box;
  background-clip: border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  -webkit-mask-composite: xor;
  position: relative;
}
.logo::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 8px;
  background: var(--gradient);
  opacity: 0.18;
}
.brand-title { font-weight: 800; font-size: 14px; letter-spacing: -0.01em; }
.brand-sub { font-size: 10px; color: var(--muted); font-weight: 500; }

.side-nav { padding: 8px; display: flex; flex-direction: column; gap: 3px; overflow: auto; }
.nav-group-title {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
  padding: 12px 10px 4px;
  user-select: none;
}
.nav-item {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 14px;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  font-weight: 500;
  font-size: 12.5px;
  transition: all 0.15s;
}
.nav-item:hover {
  border-color: var(--stroke2);
  background: var(--bg2);
  color: var(--text);
}
.nav-item.active {
  border-color: rgba(124,58,237,0.35);
  background: rgba(124,58,237,0.08);
  color: var(--accent);
  font-weight: 700;
}
html.dark .nav-item.active {
  background: rgba(124,58,237,0.15);
  color: var(--accent-light);
}
.ico {
  width: 24px;
  height: 24px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: var(--bg2);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 12px;
}

.side-bottom {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--stroke);
  display: grid;
  gap: 8px;
}

.main { min-height: 0; display: flex; flex-direction: column; gap: 14px; }
.topbar {
  border: 1px solid var(--stroke);
  border-radius: 24px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  box-shadow: var(--shadow-card);
  transition: background 0.3s;
}
.page-title { font-weight: 800; font-size: 14px; letter-spacing: -0.01em; }
.page-sub { color: var(--muted); font-size: 11px; font-weight: 500; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.search-input {
  width: 280px;
  max-width: 38vw;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: var(--bg2);
  color: var(--text);
  padding: 9px 12px;
  font-size: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}
.page-root { min-height: 0; overflow: auto; padding-bottom: 14px; }

.toast-wrap {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 999;
  display: grid;
  gap: 8px;
}

.theme-toggle {
  background: var(--bg2);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text);
  font-size: 16px;
  line-height: 1;
  transition: all 0.2s;
}
.theme-toggle:hover {
  border-color: var(--accent);
  background: rgba(124,58,237,0.08);
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
    height: auto;
  }
  .sidebar {
    width: auto !important;
  }
  .sidebar.collapsed {
    width: auto !important;
  }
  .sidebar.collapsed .brand-text,
  .sidebar.collapsed .side-bottom,
  .sidebar.collapsed .nav-item span:last-child {
    display: initial;
  }
  .sidebar.collapsed .nav-item {
    justify-content: flex-start;
  }
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-input {
    width: 100%;
    max-width: none;
  }
}
