:root{
  --text-main: #0f172a;
  --text-soft: #64748b;
  --shadow-soft: 0 10px 30px rgba(15,23,42,0.06);
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  background:
    radial-gradient(circle at top left, rgba(59,130,246,0.08), transparent 28%),
    radial-gradient(circle at top right, rgba(168,85,247,0.06), transparent 24%),
    linear-gradient(180deg, #f8fafc 0%, #f4f7fb 100%);
  color: var(--text-main);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

.soft-card {
  background: rgba(255,255,255,0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(15,23,42,0.06);
  box-shadow: var(--shadow-soft);
}

.app-scrollbar::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.app-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.45);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.app-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}

.page-shell {
  max-width: 1680px;
  margin-inline: auto;
  width: 100%;
}

.topbar-blur {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(15,23,42,0.06);
}

.cmd-k-badge {
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(15,23,42,0.08);
  box-shadow: 0 2px 8px rgba(15,23,42,0.04);
}

.topbar-search {
  box-shadow: 0 4px 20px rgba(15,23,42,0.04);
}

.app-toast {
  animation: toastIn .24s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Sidebar */
.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 286px;
  transition: width .22s ease, transform .25s ease, box-shadow .25s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 40;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

body.sidebar-collapsed .app-sidebar {
  width: 92px;
}

.app-main {
  margin-left: 286px;
  transition: margin-left .22s ease;
  min-width: 0;
  flex: 1;
}

body.sidebar-collapsed .app-main {
  margin-left: 92px;
}

.sidebar-head {
  transition: padding .18s ease;
  flex-shrink: 0;
}

.sidebar-brand-toggle {
  flex: 1;
  outline: none;
  background: transparent;
  border: 0;
}

.sidebar-brand-toggle:focus {
  outline: none;
}

.sidebar-logo-box {
  position: relative;
  height: 56px;
  width: 56px;
  border-radius: 20px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(15,23,42,0.18);
  flex-shrink: 0;
}

.sidebar-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sidebar-logo-fallback {
  display: none;
  width: 100%;
  height: 100%;
  place-items: center;
  color: white;
  font-weight: 700;
  font-size: 22px;
}

.sidebar-mobile-close {
  height: 36px;
  width: 36px;
  border-radius: 14px;
  border: 1px solid rgba(15,23,42,0.08);
  background: rgba(255,255,255,0.85);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  transition: all .18s ease;
}

.sidebar-mobile-close:hover {
  background: #f8fafc;
}

.sidebar-mobile-close svg {
  width: 18px;
  height: 18px;
}

.sidebar-link {
  position: relative;
  transition: all .18s ease;
}

.sidebar-link:hover {
  transform: translateX(2px);
}

.sidebar-link-active {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  box-shadow: 0 10px 24px rgba(37,99,235,0.24);
}

.sidebar-link::before,
.sidebar-link::after,
.sidebar-link-active::before,
.sidebar-link-active::after {
  content: none !important;
  display: none !important;
  background: transparent !important;
}

.sidebar-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-icon svg,
.sidebar-chevron svg {
  width: 20px;
  height: 20px;
}

.sidebar-label,
.sidebar-brand,
.sidebar-section-title {
  transition: opacity .16s ease, transform .16s ease;
}

body.sidebar-collapsed .sidebar-brand,
body.sidebar-collapsed .sidebar-section-title,
body.sidebar-collapsed .sidebar-submenu {
  opacity: 0;
  pointer-events: none;
}

body.sidebar-collapsed .sidebar-brand,
body.sidebar-collapsed .sidebar-section-title {
  transform: translateX(-8px);
}

body.sidebar-collapsed .sidebar-link {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

body.sidebar-collapsed .sidebar-label {
  display: none;
}

body.sidebar-collapsed .sidebar-chevron {
  display: none;
}

body.sidebar-collapsed .sidebar-head {
  padding-left: 18px;
  padding-right: 18px;
}

body.sidebar-collapsed .sidebar-logo-box {
  height: 56px;
  width: 56px;
  border-radius: 20px;
}

body.sidebar-collapsed .sidebar-brand {
  display: none;
}

.sidebar-submenu {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height .28s ease, opacity .22s ease;
}

.sidebar-submenu.is-open {
  max-height: 500px;
  opacity: 1;
}

.sidebar-sub-link {
  display: flex;
  align-items: center;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14px;
  color: #475569;
  transition: background .18s ease, color .18s ease;
}

.sidebar-sub-link:hover {
  background: rgba(248,250,252,0.95);
}

.sidebar-sub-link.is-active {
  background: #f1f5f9;
  color: #0f172a;
  font-weight: 600;
}

.sidebar-chevron {
  width: 18px;
  height: 18px;
  transition: transform .2s ease, opacity .2s ease;
  opacity: .75;
  flex-shrink: 0;
}

.sidebar-chevron.is-open {
  transform: rotate(180deg);
}

.sidebar-system {
  margin-top: auto;
  flex-shrink: 0;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 45;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}

.sidebar-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* Tom Select - base only */
.ts-wrapper {
  width: 100%;
}

.ts-wrapper.single .ts-control,
.ts-wrapper.multi .ts-control {
  min-height: 54px;
  border-radius: 16px;
  border: 1px solid rgb(226 232 240);
  background: rgb(248 250 252);
  padding: 10px 14px;
  box-shadow: none;
  display: flex;
  align-items: center;
  font-size: 16px;
  line-height: 1.4;
}

.ts-wrapper.single .ts-control .item,
.ts-wrapper.multi .ts-control .item,
.ts-wrapper.single .ts-control input,
.ts-wrapper.multi .ts-control input {
  font-size: 16px;
  line-height: 1.4;
  color: #0f172a;
}

.ts-wrapper.focus .ts-control,
.ts-wrapper.single.input-active .ts-control,
.ts-wrapper.multi.input-active .ts-control {
  border-color: rgba(37,99,235,0.55);
  box-shadow: 0 0 0 4px rgba(37,99,235,0.10);
  background: #fff;
}

.ts-dropdown {
  border-radius: 16px;
  border: 1px solid rgba(15,23,42,0.08);
  box-shadow: 0 16px 40px rgba(15,23,42,0.12);
  overflow: hidden;
  z-index: 70;
}

.ts-dropdown .option,
.ts-dropdown .create,
.ts-dropdown .no-results,
.ts-dropdown .optgroup-header {
  padding: 11px 14px;
  font-size: 15px;
  line-height: 1.4;
}

.ts-dropdown .active {
  background: #eff6ff;
  color: #0f172a;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

@media (max-width: 1023px) {
  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    transform: translateX(-100%);
    width: 286px !important;
    max-width: calc(100vw - 32px);
    box-shadow: 0 20px 60px rgba(15,23,42,0.20);
  }

  .app-sidebar.is-open {
    transform: translateX(0);
  }

  body.sidebar-collapsed .app-sidebar {
    width: 286px !important;
  }

  .app-main {
    margin-left: 0 !important;
  }
}

@media (min-width: 1024px) {
  .sidebar-overlay {
    display: none;
  }
}