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

html { -webkit-text-size-adjust: 100%; }

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body { letter-spacing: -0.005em; }

a { color: var(--color-primary); text-decoration: none; transition: color var(--dur-fast) var(--ease); }
a:hover { color: var(--color-primary-hover); }

h1, h2, h3, h4 { font-weight: 650; line-height: 1.25; letter-spacing: -0.02em; color: var(--text-primary); }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }

::selection { background: var(--color-primary-soft); color: var(--text-primary); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-pill); border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); background-clip: content-box; }

/* Page header */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.page-header .page-title { margin: 0; }
.page-title { font-size: var(--fs-2xl); margin-bottom: var(--space-lg); }
.page-subtitle { color: var(--text-secondary); font-size: var(--fs-sm); margin-top: 2px; }

.section-title {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-muted);
  margin: var(--space-lg) 0 var(--space-sm);
}

.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.muted-sm { color: var(--text-muted); font-size: var(--fs-sm); }

/* Buttons */
.btn {
  --btn-bg: var(--bg-surface);
  --btn-fg: var(--text-primary);
  --btn-bd: var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 9px 16px;
  border: 1px solid var(--btn-bd);
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 550;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.btn i { font-size: 0.95em; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  --btn-bg: var(--color-primary);
  --btn-fg: var(--color-on-primary);
  --btn-bd: var(--color-primary);
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover:not(:disabled) { --btn-bg: var(--color-primary-hover); --btn-bd: var(--color-primary-hover); }

.btn-secondary { --btn-bg: var(--bg-surface); --btn-fg: var(--text-primary); --btn-bd: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { --btn-bg: var(--bg-hover); }

.btn-ghost { --btn-bg: transparent; --btn-fg: var(--text-secondary); --btn-bd: transparent; }
.btn-ghost:hover:not(:disabled) { --btn-bg: var(--bg-hover); --btn-fg: var(--text-primary); }

.btn-danger { --btn-bg: var(--color-danger); --btn-fg: #fff; --btn-bd: var(--color-danger); }
.btn-danger:hover:not(:disabled) { filter: brightness(0.94); }

.btn-danger-soft { --btn-bg: var(--color-danger-soft); --btn-fg: var(--color-danger); --btn-bd: transparent; }
.btn-danger-soft:hover:not(:disabled) { --btn-bd: var(--color-danger); }

.btn-sm { padding: 6px 12px; font-size: var(--fs-xs); }
.btn-lg { padding: 12px 20px; font-size: var(--fs-md); }
.btn-icon { padding: 8px; width: 38px; height: 38px; }
.btn-icon.btn-sm { width: 32px; height: 32px; padding: 6px; }
.btn-block { width: 100%; }

/* Cards */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-xs);
}

.card + .card { margin-top: var(--space-md); }
.card-pad-sm { padding: var(--space-md); }

/* Badges / chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid transparent;
}

.badge-pending { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-accepted { background: var(--color-success-soft); color: var(--color-success); }
.badge-accent { background: var(--color-primary-soft); color: var(--color-primary); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* Avatar */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  object-fit: cover;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 650;
  font-size: var(--fs-md);
  flex-shrink: 0;
  overflow: hidden;
  text-transform: uppercase;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 32px; height: 32px; font-size: var(--fs-sm); }
.avatar-lg { width: 84px; height: 84px; font-size: var(--fs-2xl); }

/* Empty / loading states */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  color: var(--text-secondary);
}

.empty-state .empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-md);
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: var(--text-muted);
}

.empty-state h3 { margin-bottom: var(--space-xs); }
.empty-state p { max-width: 360px; margin: 0 auto var(--space-md); font-size: var(--fs-sm); }

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-xl);
  color: var(--text-secondary);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
  margin-bottom: var(--space-lg);
}

.toolbar .spacer { flex: 1; }

.search-field {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-field i {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1;
  width: 1rem;
  text-align: center;
  pointer-events: none;
  z-index: 1;
}

.search-field input[type="search"],
.search-field input[type="text"] {
  padding-left: 2.5rem;
}

/* Lists */
.list { display: flex; flex-direction: column; gap: var(--space-sm); }

.list-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.list-row:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.list-row-content { flex: 1; min-width: 0; }
.list-row-title { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.list-row-sub { font-size: var(--fs-sm); color: var(--text-secondary); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Card grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-md);
}

/* Utilities */
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: var(--space-sm); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); }
.wrap { flex-wrap: wrap; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}
