/* Base Reset & Common Styles */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--font-size-md);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  color: var(--text-primary);
  background: var(--bg);
  line-height: var(--line-height);
  min-height: 100vh;
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: var(--transition);
}
a:hover {
  opacity: 0.85;
}

img {
  max-width: 100%;
  display: block;
}

ul, ol {
  list-style: none;
}

input, textarea, select, button {
  font-family: inherit;
  font-size: inherit;
  outline: none;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #d9d9d9;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #bfbfbf;
}

/* Page Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.app-header .header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.app-header .header-logo {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--primary);
}

.app-header .header-role {
  font-size: var(--font-size-sm);
  color: var(--text-tertiary);
  padding: 2px 10px;
  background: var(--primary-light);
  border-radius: var(--radius-round);
}

.app-header .header-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.app-header .user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--font-size-sm);
}

.app-sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: var(--space-md) 0;
  transition: var(--transition-slow);
  z-index: 50;
}

.app-sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  border-radius: 0;
  font-size: var(--font-size-md);
  white-space: nowrap;
  overflow: hidden;
}
.nav-item:hover {
  background: var(--bg);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}
.nav-item .nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}
.nav-item .nav-label {
  flex: 1;
}

.app-main {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  padding: var(--content-padding);
  min-height: calc(100vh - var(--header-height));
  transition: var(--transition-slow);
  background: var(--bg);
}

.app-main.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed-width);
}

/* Page Header */
.page-header {
  margin-bottom: var(--space-lg);
}
.page-header h2 {
  font-size: var(--font-size-xxl);
  margin-bottom: var(--space-xs);
}
.page-header p {
  color: var(--text-secondary);
  font-size: var(--font-size-md);
}

/* Status Tags */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-round);
  font-size: var(--font-size-xs);
  font-weight: 500;
  white-space: nowrap;
}
.tag-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.tag-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.tag-error   { background: var(--error-bg); color: var(--error); border: 1px solid var(--error-border); }
.tag-info    { background: var(--info-bg); color: var(--info); border: 1px solid var(--info-border); }
.tag-default { background: var(--bg); color: var(--text-secondary); border: 1px solid var(--border); }
.tag-waiting { background: var(--waiting-bg); color: var(--waiting); border: 1px solid var(--waiting-border); }

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xxl) 0;
  color: var(--text-tertiary);
}
.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.4;
}
.empty-state p {
  font-size: var(--font-size-md);
}

/* Utility Classes */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-sm { font-size: var(--font-size-sm); }
.font-bold { font-weight: 600; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
